写一个bat将当前文件夹下图片和视频文件,将图片和视频文件的的文件名修改为对应文件的创建时间,如果时间重复在后面加上序号,并且每个步骤加上0.1s的延时,同时防止获取不到文件出现异常,最后需要点击确认
时间: 2023-06-25 21:05:23
浏览: 111
@echo off
setlocal enabledelayedexpansion
echo 1. 正在获取文件[列表](https://geek.csdn.net/educolumn/ba94496e6cfa8630df5d047358ad9719?dp_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6NDQ0MDg2MiwiZXhwIjoxNzA3MzcxOTM4LCJpYXQiOjE3MDY3NjcxMzgsInVzZXJuYW1lIjoid2VpeGluXzY4NjQ1NjQ1In0.RrTYEnMNYPC7AQdoij4SBb0kKEgHoyvF-bZOG2eGQvc&spm=1055.2569.3001.10083)...
ping 127.0.0.1 -n 1 -w 100 > nul
set count=0
for %%a in (*.jpg *.jpeg *.png *.bmp *.gif *.mp4 *.mov *.avi *.wmv) do (
set /a count+=1
set "file[!count!]=%%a"
echo 获取到 %count% 个文件
echo 2. 正在重命名文件...
ping 127.0.0.1 -n 1 -w 100 > nul
for /l %%i in (1, 1, %count%) do (
set "cur_file=!file[%%i]!"
set "file_date="
set "file_time="
for /f "usebackq delims=" %%j in (`powershell "([get](https://geek.csdn.net/educolumn/31aebce56f4ecc5451aac3a194ff6259?spm=1055.2569.3001.10083)-item '!cur_file!').cre[ati](https://geek.csdn.net/educolumn/150d7073277950db5f09620704e791cf?spm=1055.2569.3001.10083)ontime"`) do set "file_date=%%j"
for /f "usebackq delims=" %%j in (`powershell "(get-item '!cur_file!').cre[ati](https://geek.csdn.net/educolumn/150d7073277950db5f09620704e791cf?spm=1055.2569.3001.10083)ontime.to[string](https://geek.csdn.net/edu/8802d631b97a4a6af1f4d0bbf8527465?dp_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6NDQ0MDg2MiwiZXhwIjoxNzA3MzcxOTM4LCJpYXQiOjE3MDY3NjcxMzgsInVzZXJuYW1lIjoid2VpeGluXzY4NjQ1NjQ1In0.RrTYEnMNYPC7AQdoij4SBb0kKEgHoyvF-bZOG2eGQvc&spm=1055.2569.3001.10083)('HHmmss')"`) do set "file_time=%%j"
set "new_file_name=!file_date!_!file