Reputation:
Details:
I want to search in directory 'A', for a file: 'file.jar' However, directory A does not have any files directly. Instead, it is composed of over 100 subfolders: 'a1', 'a2', 'a3', 'a4', 'a5', etc.
Each subfolder has a some version of 'file.jar' How can I search and copy the newest version?
Upvotes: 0
Views: 174
Reputation: 5972
Here's a starting point: consider using FOR /R
for looping through all files recursively in a directory. A brief overview is available at ss64. Also see Rob van der Woude's page on reading file properties in a for loop. Both sites are excellent scripting resources.
For example, the following command will list all files starting with 'a' (case insensitive) in directory C:\A
and each file's last-modified date,
FOR /R C:\A %%G IN (a*) DO @ECHO %%G %%~tG
However, finding the file version itself is a bit more tricky. See How do I retrieve the version of a file from a batch file on Windows Vista?
Upvotes: 2