Get oldest file from date in filename

March 19, 2011 at 09:21:57
Specs: Windows Vista

Sorry if this has been covered before, but I need to move the oldest file fromon folder to another. The files are date stamped at the beginning of the file, and I need to use this to decide which to move.

File name is, for example, 20110101451523MyFile.txt, 20110102321723MyFile.txt - I want the earliest file to be moved from FolderA to FolderB

Can anyone please help me out?

Many thanks

See More: Get oldest file from date in filename

Report •

March 19, 2011 at 23:33:14
not tested

:: ==========================================
:: rorry.bat Sun 20-03-2011 13:29:38.70
@echo off & setLocal enableDELAYedeXpansioN

for /f "tokens=* delims= " %%a in ('dir/b/on') do (
echo move %%a d:\
goto :eof

Life is too important to be taken seriously.


Report •

October 5, 2011 at 04:28:35
what if i want to move just 5 days older files and the new one stay ... ???

Report •
Related Solutions

Ask Question