I want to create a batch script that will print all the files I have in a folder, in order of date modified

TonyT picture TonyT · Dec 23, 2013 · Viewed 15.4k times · Source

I've got no idea where to start with this :-/

I have a folder with around 500 files in it, that I would like to print off in order of date modified. I could go through and do them one by one, but why do that when I'm sure there will be a way using batch!

Please help...

Answer

MC ND picture MC ND · Dec 23, 2013

You should take a look at PrintAny.bat, which should handle the task of printing one file from batch.

For the task of doing it in modification date order, dir command will supply the list in the desired order. Then for command will handle this list, calling PrintAny to do the printing part.

for /f "tokens=*" %%f in ('dir /od /tw /b /a-d "c:\DocDir\*.*"') do (
    call printAny.bat "%%~ff"
)