HEELPBOOK - Microsoft Windows - How can I perform a batch action on a list of files from the command line? ############################## You can use the built-in "for" command to loop through a list of files. If you type the command: for /f "tokens=*" %a in ('dir /b *.*') do echo %a The command outputs only the name of each file in the current folder, which the ‘dir /b *.*’ component can do all by itself. However, you can edit the "do" portion of the command to perform a secondary task. For example, you can add the name of a batch file and the % a parameter to call the batch file on each .msg file: for /f "tokens=*" %a in ('dir /b *.msg') do datetime.bat %a In addition to outputting the name of each file in the specified folder, this command adds the current date and time to the end of each .msg filename. If you use the command in a batch file, you need to add two percent (%) signs instead of one to access the parameters. For example, if you incorporate the above command into a batch file, you would type it as: for /f "tokens=*" %%a in ('dir /b *.msg') do datetime.bat %%a ############ ARTICLE INFO ############# Article Month: March Article Date: 23/03/2012 Permalink: http://heelpbook.altervista.org/2012/microsoft-windows-how-can-i-perform-a-batch-action-on-a-list-of-files-from-the-command-line/ Source: http://www.windowsitpro.com/article/server-management/how-can-i-perform-a-batch-action-on-a-list-of-files-from-the-command-line- Language: English View more articles on: http://www.heelpbook.net/ Follow us on Facebook: http://it-it.facebook.com/pages/HeelpBook/100790870008832 Follow us on Twitter: https://twitter.com/#!/HeelpBook Follow us on RSS Feed: http://feeds.feedburner.com/Heelpbook