Copying names of files in a folder in a text document. (DOS dir Command)

I received an email the day, from a visitor Stealth SettingsWho asked us this:

[…] I searched the site (which is true, not too much) for a tutorial for copy the names of files in a folder , in a text document.
Example: I have a folder full of photos: DCS001.jpg, DCS002.jpg. DCS003.jpg, etc..
Well, I want I name these files to appear in a txt like this: DCS001, DCS002, DCS003, etc.. I understand that one can easily solve the cmd, but I did not find how. [...]

Order dir in (DCM) – (MS-DOS Commands) has the role of listing files, folders si subfolders. Order “dir", Like many other commands MS-DOS is present on all operating systems . Windows 95, 98, ME, NT, , XP... and supports a number of command lines (Syntax). 

To list files, folders and subfolders in a directory, just open Command Prompt, to navigate to the directory where the files are and to give the command "dir".

Example: On Desktop (workspace) we have the folder called “6500“. In the "6500" folder we have 60 files. Jpg (pictures) and a folder "Test - Stealth Settings“. If we want to list in CMD and / or export the file names inside the folder "6500" in a document. txt, Follow a few simple steps.

* In our case the folder "6500" has the path  D:StealthDesktop6500.

1. open and navigate to the directory "6500“. (navigation in CMD is done by command "cd nume_folder“. to change the partition, type partition letter and ":", Then press Enter)

* Users who use or Windows 7 can open the CMD directly from the current folder. Hold down the "Shift”> right click > “Open command windows here".

Open Command Windows in Folder

2. Using the command “dir”We list the contents of the folder in DCM.

dir show files

3. To Export a list of names of folders and files from inside the current folder, "6500" in our example, in a text file (.txt), we give the commanddir> list.txt".

list - dir

A file was created inside the "6500" folder lista.txt which contains all file names from folder. In addition to offering information about the volume, date and number.

list - files - dir

The "dir" command supports a series of syntax which helps us to list in several ways and sort the results as we like. A series of "dir" commands are valid only for certain operating systems.

DIR Syntax in Windows 95, Windows 98 and Windows ME

[drive:] - partition letter; [path] - the path / place where we want to execute the command.

dir [drive:] [path] / P - lists the paged results. Useful for directories with many files. You must press any key to move to the next page.

image

dir [drive:] [path] / W - lists the results on several columns.

image

dir / A - you will have to pass a specific attribute to this command.
- dir / AD - lists only directories.
- dir / AH - list only hidden files.
- dir / AS - lists only system files and folders. System Files.
- dir / AR - lists only read-only files.

dir / B - listing the files without returning results about volume and date. We export to a .txt using dir / B> lista.txt .

image

More orders "dir”And syntax supported by this command, find here.

Most syntaxes can be combined to get the results you want. We can sort the files listed by name, volume, date, extension, type… etc. Some of the "dir" command syntaxes are not available on Windows Sight yes Windows 7.

Microsoft DOS dir command in Windows XP, Windows Vista & Windows 7.

Founder and editor Stealth Settings, from 2006 to the present. Experience on operating systems Linux (in particular CentOS), Mac OS X, Windows XP> Windows 10 si WordPress (CMS).

How to » Microsoft » Copying names of files in a folder in a text document. (DOS dir Command)

1 thought on “Copying file names from a folder to a text document. (DOS dir Command) ”

Leave a Comment