批量添加视频文件创建日期和时间 - BAT脚本教程
批量添加视频文件创建日期和时间 - BAT脚本教程
本文将提供一个简单的 BAT 脚本,可以自动为视频文件(.mp4)添加创建日期和时间,方便您快速整理和管理视频文件。
脚本内容:
@echo off
setlocal enabledelayedexpansion
rem Set the date and time format
set 'dateformat=yyyyMMdd'
set 'timeformat=HHmmss'
rem Loop through all MP4 files in the current directory
for %%a in (*.mp4) do (
rem Get the creation date and time of the file
for /f 'usebackq delims=' %%b in (`wmic datafile where "name='%%~fa'" get creationdate /value ^| find "="`) do set "%%b"
for /f 'usebackq delims=' %%b in (`wmic datafile where "name='%%~fa'" get creationtime /value ^| find "="`) do set "%%b"
rem Format the date and time
set 'date=!creationdate:~0,4!!creationdate:~4,2!!creationdate:~6,2!'
set 'time=!creationtime:~0,2!!creationtime:~2,2!!creationtime:~4,2!'
rem Rename the file with the date and time
ren '%%a' '%%~na-!date!-!time!%%~xa'
)
echo All files renamed.
pause
使用说明:
- 将上面的代码复制到记事本中,将文件保存为“rename.bat”。
- 将“rename.bat”文件复制到包含要重命名的MP4文件的文件夹中。
- 双击运行“rename.bat”文件。
- 等待脚本运行完毕,所有文件将被重命名为“文件名-创建日期-创建时间.mp4”的格式。
注意:
- 该脚本仅适用于 MP4 文件。
- 脚本需要在 Windows 系统上运行。
- 运行脚本前,请备份您的视频文件,以防意外发生。
希望本教程对您有所帮助!如果您有任何问题,请随时在评论区留言。
原文地址: https://www.cveoy.top/t/topic/lC0G 著作权归作者所有。请勿转载和采集!