grab file name based on timestamp
Posted: 21 Sep 2011 13:13
Okay so ive been searching for days on this, and ive gotten close, but still cant get it.
What I need to do is take the file name "myfile.vsd" of the last modified file in the folder and set it to a variable so I can eventually print it to pdf. Now, I have everything good except the user still has to specify the name of the document to be printed.
So here is what I basically have so far:
for /f "tokens=* delims=: " %%g in ('dir %file% /-q /a:-d /t:w /od') do echo %%g
and that does nothing than what the dir command would do. So what I want to do is have %%g run through that folder and either a. pick out the filename of the last modified file and shove it in a variable or b. compare the date/time the .bat runs with the modified time of the file and kick out of the loop when the difference is minimum.
And this is going to be run multiple times daily, so the accuracy of the time has to be more precise than daily.
Any help would be awesome as this has been driving me nuts all day!
What I need to do is take the file name "myfile.vsd" of the last modified file in the folder and set it to a variable so I can eventually print it to pdf. Now, I have everything good except the user still has to specify the name of the document to be printed.
So here is what I basically have so far:
for /f "tokens=* delims=: " %%g in ('dir %file% /-q /a:-d /t:w /od') do echo %%g
and that does nothing than what the dir command would do. So what I want to do is have %%g run through that folder and either a. pick out the filename of the last modified file and shove it in a variable or b. compare the date/time the .bat runs with the modified time of the file and kick out of the loop when the difference is minimum.
And this is going to be run multiple times daily, so the accuracy of the time has to be more precise than daily.
Any help would be awesome as this has been driving me nuts all day!