Skip to content

Instantly share code, notes, and snippets.

@jshbrntt
Last active November 6, 2019 09:33
Show Gist options
  • Save jshbrntt/9314769 to your computer and use it in GitHub Desktop.
Save jshbrntt/9314769 to your computer and use it in GitHub Desktop.
Batch file to convert folder of .flac files to .mp3 using ffmpeg.
@ECHO OFF
FOR %%f IN (*.flac) DO (
echo Converting: %%f
ffmpeg -i "%%f" -ab 320k -map_metadata 0 "%%~nf.mp3"
)
echo Finished
PAUSE
@MonsterMMORPG
Copy link

how can i set different directory as ouput?

@spesvictus-zz
Copy link

For everyone else. You just put path in front of the file output. /path/to/%%~nf.mp3

@MadhukarMoogala
Copy link

Just info for future readers:

%~f         - expands %f removfng any surroundfng quotes (")
%~ff        - expands %f to a fully qualified path name
%~df        - expands %f to a drive letter only
%~pf        - expands %f to a path only
%~nf        - expands %f to a file name only
%~xf        - expands %f to a file extensfon only
%~sf        - expanded path contains short names only
%~af        - expands %f to file attributes of file
%~tf        - expands %f to date/time of file
%~zf        - expands %f to size of file
%~$PATH:f   - searches the directories listed fn the PATH
			   environment varfable and expands %f to the
			   fully qualfffed name of the first one found.
			   ff the envfronment varfable name is not
			   deffned or the file fs not found by the
			   search, then this modfffer expands to the
			   empty string

PS:
To use the FOR command in a batch program, specify %%variable instead
of %variable. Variable names are case sensitive, so %f is different
from %F

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment