Reputation: 11447
Is there a way to rename the oldest file in a directory to 'file_oldest'?
I am not sure how to combine date with ren cmd
Upvotes: 0
Views: 830
Reputation: 7117
Here you go. It's a bit trickier for a UNC path.
@echo off
setlocal
set share=\\server\xxxx\xxxx\xxxx\xxxxx
for /f "tokens=*" %%a in ('dir "%share%" /b /a-d /o-d') do (set oldest="%%a")
ren "%share%\%oldest%" file_oldest
Upvotes: 1