batch命令
找到当前文件夹中最新的文件,赋值并打印出来文件名(前缀+后缀)
for /f "tokens=*" %%a in ('dir /b /od') do set newest_zip_file=%%a
echo The most recently created file is: %newest_zip_file%
举例一
找到当前文件夹中最新的txt文件,赋值并打印出来txt文件名
for /f "tokens=*" %%a in ('dir /b /od *.txt') do set newest_txt_file=%%a
echo The most recently .txt file is: %newest_txt_file%
举例二:
找到当前文件夹中最新的zip文件,赋值并打印出来zip文件名,然后解压这个zip文件
for /f "tokens=*" %%a in ('dir /b /od *.zip') do set newest_zip_file=%%a
echo The most recently .zip file is: %newest_zip_file%
tar -xf %newest_zip_file%
标签:文件,newest,file%,zip,%%,batch,最新,file,txt From: https://www.cnblogs.com/Alan-LJP/p/17437069.html