输出文件的添加重命名视频批量 [英] Addition of output file for renaming video batch
问题描述
与感谢大卫Ruhmann,昨天我得到了我的批处理文件重命名工作视频:
With thanks to David Ruhmann, yesterday I got my batch file working for renaming videos:
@echo off
setlocal EnableExtensions EnableDelayedExpansion
:: Create Empty Folder
rd /Q "%Temp%\Temp" 2>nul & mkdir "%Temp%\Temp"
:: Loop through Folders
pushd "xPath=c:\processing"
for /d %%D in (*) do call :Process "%%~fD"
popd
goto End
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:Process <Parent>
:: Folder Name
set "xFolder=%~nx1"
:: Set Sub Folder
if not exist "%~1\VIDEO\" goto :eof
pushd "%~1\VIDEO"
:: Loop through Videos
for /f "delims=" %%A in ('dir *.avi /b') do if exist "%%~fA" (
set "xDateWritten=%%~tA"
set "xDateGMT=0000/00/00 00:00:00"
for /f "tokens=1,2" %%X in ('robocopy . "%Temp%\Temp" "%%~nxA" /TS /FP /NS /NC /NP /NJH /NJS /NDL /L') do set "xDateGMT=%%X %%Y"
rem Format = FF-FF-YYYYMMDD-HHh-MMm-SSs-FF-FF.ext
echo %xFolder:~0,2%-%xFolder:~2,2%-!xDateWritten:~6,4!!xDateWritten:~0,2!!xDateWritten:~3,2!-!xDateWritten:~11,2!h-!xDateWritten:~14,2!m-!xDateGMT:~17,2!s-%xFolder:~4,2%-%xFolder:~6,2%%%~xA
ren "%%~fA" "%xFolder:~0,2%-%xFolder:~2,2%-!xDateWritten:~6,4!!xDateWritten:~0,2!!xDateWritten:~3,2!-!xDateWritten:~11,2!h-!xDateWritten:~14,2!m-!xDateGMT:~17,2!s-%xFolder:~4,2%-%xFolder:~6,2%%%~xA"
)
popd
goto :eof
:End
endlocal
pause
但现在我需要添加额外的功能。重命名发生之后,我想剧本,导出的新文件名的随后的文件大小以字节为单位的,视频的的长度的到CSV或其他Excel兼容的文件类型。由于这些视频文件,如果我能出口的帧率的和的帧总数的为好,这将是巨大的。不知道这是连一个批处理文件的范围之内了,但。
But now I need to add an additional feature. After the renaming takes place, I would like the script to export the new filename followed by the filesize in bytes, and the length of the video to a csv or other excel-compatible filetype. As these are video files, if I could export the framerate and total number of frames as well, that would be great. Not sure if this is even within the scope of a batch file anymore though.
推荐答案
下面是名称和大小导出为CSV文件的修改。
Here is a modification to export the name and size to a csv file.
更改此
echo %xFolder:~0,2%-%xFolder:~2,2%-!xDateWritten:~6,4!!xDateWritten:~0,2!!xDateWritten:~3,2!-!xDateWritten:~11,2!h-!xDateWritten:~14,2!m-!xDateGMT:~17,2!s-%xFolder:~4,2%-%xFolder:~6,2%%%~xA
ren "%%~fA" "%xFolder:~0,2%-%xFolder:~2,2%-!xDateWritten:~6,4!!xDateWritten:~0,2!!xDateWritten:~3,2!-!xDateWritten:~11,2!h-!xDateWritten:~14,2!m-!xDateGMT:~17,2!s-%xFolder:~4,2%-%xFolder:~6,2%%%~xA"
进入这个
set "xFrame=00,00000"
for /f %%X in ('exiftool -p "$Framerate,$Framecount" "%%~fA"') do set "xFrame=%%~X"
set "xSize=%%~zA"
set "xName=%xFolder:~0,2%-%xFolder:~2,2%-!xDateWritten:~6,4!!xDateWritten:~0,2!!xDateWritten:~3,2!-!xDateWritten:~11,2!h-!xDateWritten:~14,2!m-!xDateGMT:~17,2!s-%xFolder:~4,2%-%xFolder:~6,2%%%~xA"
echo !xName!
ren "%%~fA" "!xName!"
echo !xName!,!xSize!,!xFrame!>>C:\RenameOutput.csv
更新:
要获取媒体文件的信息,我们将不得不使用第三方工具。如
To obtain the media file information we will have to use a 3rd party tool. Such as
- ExifTool
- MediaInfo
- FFmpeg
根据快速浏览一下ExifTool和MediaInfo,我喜欢MediaInfo其更一致的媒体文件持续时间的输出格式更好。如何分析信息的例子。
Based on a quick look at ExifTool and MediaInfo, I like MediaInfo better for its more consistent media file Duration output format. Example of how to parse the information.
for /f "tokens=2,*" %X in ('mediainfo file.avi ^| find "Duration "') do @echo %Y
更新2:
添加exiftool例子来回答。
Added exiftool example to the answer.
这篇关于输出文件的添加重命名视频批量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!