Computer Hope
Microsoft => Microsoft DOS => Topic started by: pleaselogin on February 18, 2010, 12:41:49 AM
-
Hi All!
Is there a way to ensure that the set of files identified in a FOR command are processed in alphabetical order without explicitly naming each file (in my case, all PDF files)? This list of PDF files changes dynamically.
FOR %%Z IN (*.pdf) DO <whatever>...
If I use what I have here, the process picks up any file in the directory, regardless of order. Maybe there's a way to dynamically dump a list of names for all PDF files within a directory into a variable and then I could pass the variable as the set of files...
-
You can process the output of a command, so make the command a sorted directory listing :
for /f "delims=" %A in ( 'dir /b/on *.pdf' ) do <whatever>... %A
-
Thanks, gpl. I actually got that close, except I forgot the single quotes inside the brackets and couldn't figure it out.