Reputation: 75
I have a number of files in my c:\Test
folder. I want to move the oldest modified file (file which was modified first) to another location. I am very new to scripting.
Could you help me with this issue?
Upvotes: 3
Views: 3211
Reputation: 67216
@echo off
cd c:\Test
for /F "delims=" %%a in ('dir /B /A:-D /O:D /T:W') do (
move "%%a" C:\Another\Location
goto continue
)
:continue
Upvotes: 2
Reputation: 1855
If you have cygwin ls -ca
gives you a list of files sorted in order of modification time. Take the last one (tail -1) and move it where you want to.
Upvotes: 1