Windows Batch - Change the beginning of a path but keep the rest -
i'm running ffmpeg video encoding. have batch file encode files drop on it, keeping file's original name , re-create encoded files specific directory. script "know" original's file path , re-create encoded file path relative it, meaning: original file dropped on batch file in c:\some\folder\show\season\episode\file.mov encoded file should encoded d:\different\directory\show\season\episode\file.mp4 part of path until \show fixed.
this have far:
@echo on set count=0 %%a in (%*) (<br> if exist %%a ( md \\specific\path\"%%~na" %myfiles%\ffmpeg.exe -i "%%~a" -vcodec libx264 -preset medium -vprofile baseline -level 3.0 -b 500k -vf scale=640:-1 -acodec aac -strict -2 -ac 2 -ab 64k -ar 48000 "%%~na_500.mp4" re-create "%%~na_500.mp4" "\\specific\path\"%%~na"\%%~na_500.mp4" re-create "%%~na_500.mp4" "\\specific\path\"%%~na"\%%~na_500.mp4" del "%%~na_500.mp4"
set /a count+=1
) else ( echo skipping non-existent %%~a
thank you, oren
class="lang-dos prettyprint-override">@echo off setlocal set "myfiles=my_files" set "fixed_path=u:\destdir" %%a in ("%*") if exist "%%a" ( /f "tokens=3*delims=\" %%b in ("%%~dpa") ( echo(md "%fixed_path%\%%c" echo(%myfiles%\ffmpeg.exe -i "%%~a" -vcodec libx264 -preset medium -vprofile baseline -level 3.0 -b 500k -vf scale=640:-1 -acodec aac -strict -2 -ac 2 -ab 64k -ar 48000 "%%~na_500.mp4" echo(copy "%%~na_500.mp4" "%fixed_path%\%%c%%~na_500.mp4" echo(del "%%~na_500.mp4" ) ) else (echo(%%~a not exist ) goto :eof
the required md commands simply echo
ed testing purposes. after you've verified commands correct, alter echo(md
md
create directories. append 2>nul
suppress error messages (eg. when directory exists)
similarly, del
, copy
commands simply echoed.
i set myfiles
constant - no uncertainty yours different , set fixed _path
constant convenience of editing.
no thought whether ffmpeg
command right - edited yours, , i'm puzzled utilize of 2 apparently identical copy
commands in succession, maybe eyes playing tricks...
windows batch-file ffmpeg
No comments:
Post a Comment