Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法将目录中最旧的文件重命名为“file_oldest”? 我不知道如何将日期与 ren cmd
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