Hi guys,
Couldn't really find a .bat related forum so have stuck in here as seems most relevant!
Relatively new to batch files so bear with me....
Need to write one that shall find the newest file in 4 different folders....
\\s90\Downloads\PART WKLY1\
\\s90\Downloads\PART WKLY2\
\\s90\Downloads\PART WKLY3\
\\s90\Downloads\PART WKLY4\
the files that come into here have no extension, i then need to rename the file to have a .zip extension. and then move all four files to one single folder...
\\s60\PART WKLY\
The renaming, moving etc etc - i can do but only know how to do it with a given filename...
Unsure how to find the newest file - and then i'm guessing i need to store that file name in some sort of varialble as it shall need to be referenced throughout the rest of the code.
have tried the following - taken off of a blog somewhere on how to find newest file and store in variable....but doesn't seem to be working...
any help greatly appreciated!
Cheers,
Dan
Couldn't really find a .bat related forum so have stuck in here as seems most relevant!
Relatively new to batch files so bear with me....
Need to write one that shall find the newest file in 4 different folders....
\\s90\Downloads\PART WKLY1\
\\s90\Downloads\PART WKLY2\
\\s90\Downloads\PART WKLY3\
\\s90\Downloads\PART WKLY4\
the files that come into here have no extension, i then need to rename the file to have a .zip extension. and then move all four files to one single folder...
\\s60\PART WKLY\
The renaming, moving etc etc - i can do but only know how to do it with a given filename...
Unsure how to find the newest file - and then i'm guessing i need to store that file name in some sort of varialble as it shall need to be referenced throughout the rest of the code.
have tried the following - taken off of a blog somewhere on how to find newest file and store in variable....but doesn't seem to be working...
Code:
::Find newest file and save it in a variable
FOR /F "delims=|" %%I IN ('\\s90\Downloads\PART WKLY1\"*.*" /B /O:D') DO SET NewestFile=%%I
::Rename
ren \\s90\Downloads\PART WKLY1\%NewestFile% \\s60\PART WKLY\%NewestFile%.zip
any help greatly appreciated!
Cheers,
Dan