回复 1# zxar520
请参考Q-04把bat文件保存为ANSI编码:
https://mp.weixin.qq.com/s/Koje4FufWxWBs7ioDy_LJA- @echo off
- setlocal enabledelayedexpansion
- cd /d "%~dp0"
- for /f "delims=" %%i in ('dir /b /a-d *.mp4') do (
- set "OldName=%%~ni"
- REM 假设文件名格式是 real1662447316.mp4
- set "TimeSecs=!OldName:~4!"
- call :SecsToDate !TimeSecs! TimeYear TimeMonth TimeDay TimeHour TimeMinute TimeSecond
- set "NewName=!OldName:~0,4!!TimeYear!-!TimeMonth!-!TimeDay!-!TimeHour!-!TimeMinute!-!TimeSecond!%%~xi"
- echo From [%%i] To [!NewName!]
- ren "%%i" "!NewName!"
- )
- goto :eof
-
- :SecsToDate %secs% yy mm dd hh nn ss
- setlocal ENABLEEXTENSIONS
- set /a i=%1,ss=i%%60,i/=60,nn=i%%60,i/=60,hh=i%%24,dd=i/24,i/=24
- set /a a=i+2472632,b=4*a+3,b/=146097,c=-b*146097,c/=4,c+=a
- set /a d=4*c+3,d/=1461,e=-1461*d,e/=4,e+=c,m=5*e+2,m/=153,dd=153*m+2,dd/=5
- set /a dd=-dd+e+1,mm=-m/10,mm*=12,mm+=m+3,yy=b*100+d-4800+m/10
- (if %mm% LSS 10 set mm=0%mm%)&(if %dd% LSS 10 set dd=0%dd%)
- (if %hh% LSS 10 set hh=0%hh%)&(if %nn% LSS 10 set nn=0%nn%)
- if %ss% LSS 10 set ss=0%ss%
- endlocal&set %7=%ss%&set %6=%nn%&set %5=%hh%&^
- set %4=%dd%&set %3=%mm%&set %2=%yy%&goto :EOF
复制代码
|