Reputation: 1
I have a batch script to run ffmpeg on files recursively. Currently the script saves all the new files to a newly created directory named Output. Instead, I would like to save the new files in the same location as the original files. I thought I would use an environmental variable showing the current directory being traversed to during recursion but I can't find it.
SET /P i=Enter the file extension
md output
For /R %%a IN (*.%i%) DO ffmpeg -i "%%a" -c:v libx264 -crf 10 -pix_fmt yuv420p "output/%%~na.mp4"
The script works fine saving the file as the same filename with a new extension but places the file in the new "output" folder. I tried setting a new variable with %cd% within the FOR loop but that didn't work.
Upvotes: 0
Views: 69
Reputation: 80213
... "%%~dpna.mp4"
should do this.
Note that in the Windows world, \
is a directory-separator and /
is a switch-indicator. Windows often, but not always, makes the translation. Best to use the correct form.
Metavariable modifiers are documented under for /?
from the prompt. They are d
for drive
, p
for path
, n
for name
and x
for extension. z
will give you size, s
shortname, t
datestamp, a
attribute and f
will yield the fully-qualified filename within limits). Note that the path
resulting wil contain both leading and trailing \
but not \\
.
Upvotes: 1