Hi, please can me help?
thanks to ndjamena I have modify this to convert .avi in .mxf files
Now I would like assume that current dir as destfolder, for example, if I have c:\cats\c0001.avi the script have to assume c:\cats as destFolder
How can I change the script? (in this momenti the dest folder is v:\automazioneclip\output\broadcast)
thanks
ps. I use the batch in drag and drop mode
Code:@rem unless otherwise specified for debugging reasons turn echo off @if "%EMode%"=="" Set EMode=ON @ECHO %EMode% @ECHO off SetLocal DisableDelayedExpansion Set "EXTLIST=*.avi" Set "DoPop=0" Set "ARGLVL=0" Set "FileName-DQ=" Set VDM_LOC="v:\automazioneclip\VirtualDubMOD\virtualdubmod.exe" set "DestFolder=v:\automazioneclip\output\broadcast" Set "WorkFolder=%DestFolder%" if not exist %DestFolder% mkdir %DestFolder% rem process the arguments one by one :ARGS rem if there are no further arguments then exit the batch. if [%1]==[] ( if "%ARGLVL%"=="0" ( CALL :GetTargetName EndLocal pause ) goto :eof ) rem wildcard processing Set "FileName=%~1" if "%FileName%"=="" ( SHIFT goto :ARGS ) rem if the argument doesn't exist in the file system in any form skip it. if NOT EXIST %1 ( SHIFT goto :ARGS ) if NOT [%1]==[] if NOT "%FileName:^*=%%FileName:^?=%"=="%FileName%%FileName%" ( for %%w in (%1) DO ( Set /a ARGLVL+=1 CALL :ARGS "%%~fw" Set /a ARGLVL-=1 ) SHIFT goto :ARGS ) Set "FileName=" rem Set search/recursion variables Set "Pattern=%EXTLIST%" Set "STARTLVL=0" Set "FOUNDLVL=1024" rem if the argument is the current directory then process everything in it. if "%~f1"=="%CD%" ( rem echo Processing Directory "%CD%" CALL :START %1 SHIFT goto :ARGS ) rem Test if the argument is a directory, if it is move to it then process everything in it, if not then move to the file's parent directory and process the file. Then return to starting directory. Type NUL pushd "%~f1" 2> nul if NOT "%errorlevel%"=="0" ( if NOT "%CD%\"=="%~dp1" ( pushd "%~dp1" Set "DoPop=1" ) Set Pattern="%~nx1" ) else ( rem echo Processing Directory "%~f1" Set "DoPop=1" ) CALL :START %1 if "%DoPop%"=="1" ( popd Set "DoPop=0" ) SHIFT goto :ARGS :START <CURRENT_ARG> rem Count is superseded by FOUNDLVL but may still be useful for renaming purposes Set "Count=0" rem Process all files in the current directory fitting the arguments search pattern. for /f "delims=" %%y in ('dir %Pattern% /b /od /a-d') do ( if /I NOT "%%~y"=="File Not Found" CALL :Process_File "%%~fy" ) rem if it didn't find anything search all directories instead goto :eof if "%Count%"=="0" if %STARTLVL% LSS %FOUNDLVL% ( for /d %%b in (*) do ( pushd "%%~fb" rem echo Processing Directory "%%~fb" Set /a STARTLVL+=1 CALL :START "%%~fb" Set /a STARTLVL-=1 popd ) ) goto :eof :Process_File <AVI_FILENAME> Set /a Count+=1 Set "FOUNDLVL=%STARTLVL%" echo Processing "%CD%\%~nx1" if /I NOT "%~x1"==".avi" ( echo "%~nx1" echo is not a .avi file pause goto :eof ) if EXIST "%DestFolder%\%~n1.avi" ( echo File già esistente nella directory di destinazione %DestFolder% goto :eof ) if EXIST "%WorkFolder%\%~n1.mp4" ( echo Working File Already Exists... goto :eof pause ) SetLocal DisableDelayedExpansion if exist "%~dpn1.wav" ( set "Audio=%~dpn1.wav" ) else ( set "Audio=v:\automazioneclip\system\empty.wav") rem Find TimeCode Info Set AUCount=0; for /f "tokens=1,2 delims=^=" %%g in ('v:\automazioneclip\virtualdubmod\FFProbe -hide_banner -loglevel fatal -pretty -show_streams -show_entries stream^=codec_type^,codec_tag_string^,width^,height^,sample_aspect_ratio:stream_disposition^=:format_tags^=timecode^,company_name^,product_name^,product_version "%~1" 2^>^&1') DO ( if "%%~g"=="TAG:company_name" set "T_Company_Name=%%~h" if "%%~g"=="TAG:product_name" set "T_Product_Name=%%~h" if "%%~g"=="TAG:product_version" set "T_Product_Version=%%~h" if "%%~g"=="TAG:timecode" set "TIMECODE=%%~h" if "%%~g"=="width" set "V_Width=%%~h" if "%%~g"=="height" set "V_Height=%%~h" if "%%~g"=="sample_aspect_ratio" set "V_PAR=%%~h" if "%%~g"=="codec_tag_string" set "codec_tag_string=%%~h" if "%%~g"=="codec_type" if "%%~h"=="audio" set /a AUCount+=1 ) if "%V_Width%"=="" ( echo ERROR: Video Width NOT FOUND! pause goto :eof ) if "%codec_tag_string%"=="" ( echo ERROR: no codec tag FOUND! pause goto :eof ) if "%V_Height%"=="" ( echo ERROR: Video Height NOT FOUND! pause goto :eof ) if "%V_PAR%"=="" ( echo ERROR: Video PAR NOT FOUND! pause goto :eof ) rem Set "V_Q=UD" rem if %V_Width% LEQ 1920 if %V_Height% LEQ 1120 \\ Set "V_Q=HD" rem if %V_Width% LEQ 1280 if %V_Height% LEQ 752 Set "V_Q=MD" if %V_Width% LEQ 1024 if %V_Height% LEQ 608 Set "V_Q=SD" echo Using %V_Q% Mode echo PAR = %V_PAR% if NOT "%TimeCode%"=="" echo Timecode= %TIMECODE% if "%codec_tag_string%"=="YUY2" (CALL :MAKEVCF_YUY2 "%WorkFolder%\%~n1.vcf" "%WorkFolder%\%~n1.avs" "%WorkFolder%\%~n1.avi" "%~f1") if "%codec_tag_string%"=="UYVY" (CALL :MAKEVCF_UYVY "%WorkFolder%\%~n1.vcf" "%WorkFolder%\%~n1.avs" "%WorkFolder%\%~n1.avi" "%~f1") if "%codec_tag_string%"=="MJPG" (CALL :MAKEVCF_MJPG "%WorkFolder%\%~n1.vcf" "%WorkFolder%\%~n1.avs" "%WorkFolder%\%~n1.avi" "%~f1") rem CALL :MAKEVCF "%WorkFolder%\%~n1.vcf" "%WorkFolder%\%~n1.avs" "%WorkFolder%\%~n1.avi" "%~f1" echo FATTO echo. echo --------------------------------------------- echo. EndLocal goto :eof :MAKEVCF_YUY2 <VCF_FILENAME> <AVS_FILENAME> <AVI_FILENAME> <avi_FILENAME> v:\automazioneclip\core\ffmbc -y -i "%CD%\%~n1.avi" -i "%Audio%" -target imx50 -aspect 16:9 %WorkFolder%\%~n1.mxf goto :eof :MAKEVCF_UYVY <VCF_FILENAME> <AVS_FILENAME> <AVI_FILENAME> <avi_FILENAME> v:\automazioneclip\core\ffmbc -y -i "%CD%\%~n1.avi" -i "%Audio%" -target imx50 -aspect 16:9 %WorkFolder%\%~n1.mxf goto :eof :MAKEVCF_MJPG <VCF_FILENAME> <AVS_FILENAME> <AVI_FILENAME> <avi_FILENAME> v:\automazioneclip\core\ffmpeg.exe -y -i "%CD%\%~n1.avi" -pix_fmt yuvj422p -an -f rawvideo -| v:\automazioneclip\core\ffmbc.exe -y -f rawvideo -pix_fmt yuv422p -s 720x576 -r 25 -i - -tff -i "%Audio%" -target imx50 -aspect 16:9 %WorkFolder%\%~n1.mxf goto :eof :GetTargetName Set "FileName=" Set /p FileName=InputFileName.mxf o InputFolder - INVIO per convertire tutto (EXIT esce): rem Add or remove double-quotes if necessary if NOT DEFINED FileName ( Set "FileName-DQ=" goto :DQSkip ) Set "FileName-DQ=%FileName:"=%" if NOT DEFINED FileName-DQ ( Set "FileName=" Set "FileName-DQ=" goto :DQSkip ) if EXIST "%FileName-DQ%" ( if "%FileName-DQ%"=="%FileName-DQ: =%" ( Set "FileName=%FileName-DQ%" ) else ( Set FileName="%FileName-DQ%" ) ) :DQSkip if /I "%FileName-DQ%"=="" Set FileName="%CD%" if /I "%FileName-DQ%"=="CD" Set FileName="%CD%" if /I "%FileName-DQ%"=="EXIT" goto :eof if /I "%FileName-DQ%"=="NOEXIT" goto :GetTargetName if DEFINED FileName ( Set /a ARGLVL+=1 CALL :ARGS %FileName% Set /a ARGLVL-=1 ) goto :GetTargetName
+ Reply to Thread
Results 1 to 8 of 8
-
-
That's not actually how batch works, it's not even a logical question. What do you think the 'Current Folder' actually is? Try this:
Code:echo %CD% pause
If you want the folder the batch file resides in it's "%~dp0". -
Code:
set "DestFolder=v:\automazioneclip\output\broadcast"
Code:set "DestFolder=."
Last edited by ndjamena; 24th Jun 2014 at 09:00.
-
Be careful: the default current directory can be different depending on what version of Windows you are running and how the batch file is started.