Hi guys,
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\
any help greatly appreciated!
Cheers,
Dan
Find newest file
Moderator: DosItHelp
Re: Find newest file
Probably something like that
Regards
aGerman
Code: Select all
@echo off &setlocal
for /f "delims=" %%a in ('dir /a-d /b /o-d "\\s90\Downloads\PART WKLY1"') do (set "name=%%a" &goto :exitFor1)
:exitFor1
move "\\s90\Downloads\PART WKLY1\%name%" "\\s60\PART WKLY\%name%.zip"
for /f "delims=" %%a in ('dir /a-d /b /o-d "\\s90\Downloads\PART WKLY2"') do (set "name=%%a" &goto :exitFor2)
:exitFor2
move "\\s90\Downloads\PART WKLY2\%name%" "\\s60\PART WKLY\%name%.zip"
for /f "delims=" %%a in ('dir /a-d /b /o-d "\\s90\Downloads\PART WKLY3"') do (set "name=%%a" &goto :exitFor3)
:exitFor3
move "\\s90\Downloads\PART WKLY3\%name%" "\\s60\PART WKLY\%name%.zip"
for /f "delims=" %%a in ('dir /a-d /b /o-d "\\s90\Downloads\PART WKLY4"') do (set "name=%%a" &goto :exitFor4)
:exitFor4
move "\\s90\Downloads\PART WKLY4\%name%" "\\s60\PART WKLY\%name%.zip"
Regards
aGerman
Re: Find newest file
Thanks for the reply - doing what i asked for.... one small thing... it seems to be working off of the 'date modified' date.... is there any way to get it to work off of the 'date created' instead?
Cheers,
Dan.
Cheers,
Dan.
Re: Find newest file
Try to start all FOR loops this way:
for /f "delims=" %%a in ('dir /a-d /b /o-d /tc "\\s90...
Regards
aGerman
for /f "delims=" %%a in ('dir /a-d /b /o-d /tc "\\s90...
Regards
aGerman