Batch to transfer highest numbered folder

March 22, 2011 at 04:20:53
Specs: Windows Server 2003

I have a backup script that backs up files into dated directories, for example 20110322, one for each day, so I have backups from different days. I'm trying to write a batch script that takes just the LATEST folder (i.e. the one that bears the latest date) and copies it to an external drive. When files are sorted by name, the file I want to transfer appears at the end, so presumably this should be quite simple?

Is this possible, and could someone give me some pointers?

Many thanks in advance.

See More: Batch to transfer highest numbered folder

Report •

March 22, 2011 at 09:07:26
@echo off
pushd  The folder holding the dated directories
for /F "delims=" %%j in ('dir /B /AD-H /O-N 20*') do (
  xcopy "%%j" Destination
  goto :DONE

Report •

March 28, 2011 at 02:15:56
Thanks very much for posting this. This seems to use the current date, though, and I need a batch script that looks for the folder with the MOST RECENT date, which may not be today's date.



I would like 20110328 to be copied.

Is this possible?

Report •
Related Solutions

Ask Question