1

当前代码:

@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-HHhMMmSSs-FF-FF.ext
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:\processing\RenameOutput.csv
)
popd
goto :eof


:End
endlocal
pause

我以前认为我的文件夹结构将是前:

C:\处理\15010107\视频\files.avi

,但实际上是

C:\processing\15010107\Video\filedate\files.avi

,所以我需要它比以前多搜索 1 个子文件夹。

此外,重命名的文件需要有24 小时格式的时间,它当前正在输出 pm 时间但没有 pm 标志,这可能与 am 文件混淆。

4

1 回答 1

1

我相信这些更改应该涵盖您的新问题。

  1. 将文件夹循环更改为也循环遍历子filedate文件夹。
  2. Process函数现在采用两个参数parent文件夹和current文件夹。
  3. 小时现在调整为 24 小时格式。

完整脚本(添加评论)

@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 if exist "%%~fD\VIDEO\" (
    pushd "%%~fD\VIDEO\"
    for /d %%S in (*) do call :Process "%%~fD" "%%~fS"
    popd
)
popd
goto End


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:Process <Parent> <Working>
:: Folder Name
set "xFolder=%~nx1"

:: Set Working Directory
if not exist "%~f2" goto :eof
pushd "%~f2"

:: Loop through Videos
for /f "delims=" %%A in ('dir *.avi /b') do if exist "%%~fA" (
    rem Retrieve the file time stamp
    set "xDateWritten=%%~tA"
    rem Retrieve the Seconds using RoboCopy
    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 Retrieve the Video frame information
    set "xFrame=00,00000"
    for /f %%X in ('exiftool -p "$Framerate,$Framecount" "%%~fA"') do set "xFrame=%%~X"
    rem Retrieve the file size
    set "xSize=%%~zA"
    rem Adjust to 24 hours
    set "xHour=!xDateWritten:~11,2!"
    if "!xDateWritten:~17,2!"=="PM" set /a "xHour+=12"
    rem Format = FF-FF-YYYYMMDD-HHh-MMm-SSs-FF-FF.ext
    set "xName=%xFolder:~0,2%-%xFolder:~2,2%-!xDateWritten:~6,4!!xDateWritten:~0,2!!xDateWritten:~3,2!-!xHour!h-!xDateWritten:~14,2!m-!xDateGMT:~17,2!s-%xFolder:~4,2%-%xFolder:~6,2%%%~xA"
    rem Display, Rename, and Save
    echo !xName!
    ren "%%~fA" "!xName!"
    echo !xName!,!xSize!,!xFrame!>>C:\processing\RenameOutput.csv
)
popd
goto :eof


:End
endlocal
pause
于 2013-01-10T22:29:59.860 回答