| 1. |
Solve : Batch file to execute a command in the most recent folder at a specific place? |
|
Answer» Hi All I really really hope this makes sense to someone other then me Not so much. I figure your folder structure looks something like this: Quote workspace Now please explain the source and target of this copy you want to do. Quote I want to create a batch file that will determine which build is most recent (either by build number or date) This is where I get lost. If it's TRUE that build number 2.8_test_4 is more recent than 2.6_test_4, you could sort the folders descending by date, take the first folder in the list and sort the build files descending by date. The file at the top of the list would be the most recent build. Hi Sidewinder The folder structure does indeed look like that with possibly 4 or 5 builds added to each folder daily. What i would like to be able to do is at any point in the day run a batch file that will go and pick up the 'newest' build from each folder and copy these to ANOTHER location, The copy part of the batch file isn't a problem but i need a way for the batch file to determine what the 'newest' build is in each folder regardless of what number that build might be. I understand that this is quite TRICKY due to the way microsoft set there dates but I'm hoping there is a way i can get it to pick up the 'hightest' build number from each folder. does that help any? thanks again aj Quote I understand that this is quite tricky due to the way microsoft set there dates Actually not. The display dates are locally formated by the user. The dates are stored internally in Universal Time Coordinate (UTC) format. Quote What i would like to be able to do is at any point in the day run a batch file that will go and pick up the 'newest' build from each folder and copy these to another location This may help: Code: [Select]@echo off setlocal enabledelayedexpansion for /f "tokens=* delims=" %%v in ('dir e:\workspace /b /a:d') do ( set first=Y for /f "tokens=* delims=" %%x in ('dir e:\workspace\%%v /a:-d /b /o:-d') do ( if !first!==Y copy e:\workspace\%%v\%%x ..... set first=N ) ) Based on your naming convention, be sure not to overwrite any files. The copy statement is incomplete, used for demo purposes. |
|