The final code > get_files.txt directs and appends all the output to a text file called get_files.txt which is necessary because the script is repeated several times as it recurses each folder and so we want to collate all the names into a single file. The do echo %%a script executes the echo %%a command that simply displays the current file being read in the current folder name which is represented by the variable. The in (*) bit is the set of files to match, which in this case is everything denoted by using the * wildcard character. The variable name %%a is used to hold the current folder being traversed. The addition of the /r switch is to tell the script to recurse all directories and subdirectories from where the script is run. ![]() The for command here is used to run a further command for each file or folder in the set. Copy the code into Notepad or other text editor and save it as get_files.bat:įor /r %%a in (*) do echo %%a > get_files.txt Simple and straightforward this one, a script to list all files in a directory and all corresponding subdirectories. List all files in a directory and subdirectory ![]() DOS has always been handy for creating the type of batch files that XP could never handle well so here are a few scripts you might find useful.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |