| 1. |
Solve : HandbrakeCLI: use same target file name as source file name? |
|
Answer» Hi, In a batch file variables have percent signs before and after like this %filename%There are some others with exclamation marks but we don't need to go there right now. Sorry but you didn't understand what I mean (ENGLISH is not my first language). I use a media center software with infrared remote control. No keyboard. Inside this software I press a button to start handbrake. By pressing this button this commands will be send: handbrakecli.exe -i f:/videos -o f:/videos/movie.mkv "-i" means INPUT. "-o" means OUTPUT. So handbrake is searching for a TS file inside the folder "videos" and then encodes to mkv format. THe encoded movie gets the name "movie.mkv". That means: everytime I start an encoding process the mkv movie gets the name "movie.mkv". That's bad. ALso I can send this handbrakecli.exe -i f:/videos/hangover.ts -o f:/videos/hangover.mkv Thats means: handbrake only encodes the movie hangover.ts to hangover.mkv Now I need an automatically detection of the movie name. Something like this: handbrakecli.exe -i f:/videos/%filename%.ts -o f:/videos/%filename%.mkv But at this point the variable %filename% is empty. So: how can I prior to that store the the movie name in the variable %filename%. I think I need a batch that looks inside the folder "videos" for a movie in TS format and when there is a movie then the movie name needs to be STORED in the variable %filename%. But how can I acchieve this? olli14 The FOR command can list all the files in the directory. Code: [Select]FOR %%G in (*.ts) do echo %%G[code]To expand on Squashman's code: Code: [Select]@echo off FOR %%G in ("f:\videos\*.ts") do "handbrakecli.exe" -i "%%~G" -o "%%~nG.mkv"It's working great. Thanks. |
|