Solved: Need help batch renaming video files in a specific format

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Shiken

Thread Starter
Joined
Dec 27, 2012
Messages
1
I am working on renaming files that come from digital camera video recordings. They output files in a generic incremental filename of which I do not need any information from. My folder structure is:
Code:
x:\processing\01020304\VIDEO\0001.avi
The filename I am trying to achieve would be for this example:

Code:
01-02-20121227-07h30m00s-03-04.avi
In this example, 01-02 is the first 4 numbers of the \01020304\ folder. 20121227 is the date the video was created, with 07h30m00s as the ending time of the video, which is usually reported by the "last modified time". finally the 03-04 is the second half of the folder name used previously.

I'm a complete novice to writing batch files like this, but was unable to find any other examples similar enough to get myself started, so any help would be greatly appreciated.

Edit:
So far, I've found / put this together, but it currently only works for the folder manually set. need to figure out a loop of sorts to check all subfolders of \processing\.
Code:
@echo off
setlocal EnableExtensions EnableDelayedExpansion

:: Setup
rd /Q "%Temp%\Temp" & mkdir "%Temp%\Temp" 2>nul
set "xPath=c:\processing\01010101\VIDEO"
set "xFolder="

:: Parse Folder Name
for /f "tokens=3 delims=\" %%A in ("%xPath%") do set "xFolder=%%A"

:: Loop through Videos
pushd %xPath%
for /f "tokens=1,2,3,4,*" %%A in ('dir *.avi /T:W /4') do if exist "%%~fE" (
    set "xDateWritten=%%~tE"
    set "xDateCreated=%%~A %%~B %%~C"
    set "xDateGMT=0000000000000000000"
    for /f "tokens=1,2" %%X in ('robocopy . "%Temp%\Temp" "%%~E" /TS /FP /NS /NC 

/NP /NJH /NJS /NDL /L') do set "xDateGMT=%%X %%Y"
    echo %xFolder:~0,2%-%xFolder:~2,2%-!xDateCreated:~6,4!!xDateCreated:~0,2!!

xDateCreated:~3,2!-!xDateWritten:~11,2!h-!xDateWritten:~14,2!m-!xDateGMT:~17,2!s-%

xFolder:~4,2%-%xFolder:~6,2%%%~xE
)
popd

endlocal
pause
EDIT2: resolved at stack overflow. end result:
Code:
@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
)
popd
goto :eof


:End
endlocal
pause
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Members online

Top