Edit filename variable in Batch script

musras
musras used Ask the Experts™
on
I am reencoding a massive bunch of AVI's to MP4 using Handbrake CLI:

*** script start

for %%i in (*.avi) do (

"D:\reencode\handbrake\HandBrakeCLI.exe" -i "%%i" -t 1 -c 1 -o "%%~ni.mp4" -f mp4 -X 480 -e x264 -q 0.59 -a 1 -E faac -B 128 -R 48 -6 dpl2 -D 1 -x level=30:cabac=0:ref=2:mixed-refs=1:analyse=all:me=umh:no-fast-pskip=1 -v

move "%%i" "D:\reencode\AVI\finished"
)

*** script end

the "move" command will execute as:
      move video001.avi "D:\reencode\finished"

How can I add a second "move" command so "%%i" is modified from "video001.avi" to "video001.mp4", so the reencoded file is also moved?


Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
move  "%%~ni.mp4"  "D:\reencode\AVI\finished"

Author

Commented:
Thanks so much - it looks so simple, yet i don't understand how that works :/

Google is no help when searching for those special characters, so i'm having some trouble figuring out why it works...

How does %%~ni  strip the extension off the filename?

Could you perhaps show me where to find more info about this?
Bill PrewTest your restores, not your backups...
Top Expert 2016

Commented:
Check out the following at a command prompt, they will give you decent help on the commands and options:

FOR /?
SET /?

In addition, here are a few sites with decent reference info for batch commands.

http://ss64.com/nt/
http://www.robvanderwoude.com/
http://www.dostips.com/
http://www.computerhope.com/batch.htm

~bp

Author

Commented:
thanks so much for your help knightEknight and billprew :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial