Posted By

shadevampire on 08/25/11


Tagged

file windows files directory music in convert ffmpeg


Versions (?)

Convert every music file into 192kbps mp3 in a given "targetdir" folder with ffmpeg on Windows


 / Published in: Windows PowerShell
 

  1. @ECHO OFF
  2.  
  3. REM usage: put files to targetdir (default is named "put_files_here") folder and change the convert formats in the for loop to match what you want to do if you need a different format. Then you simply run this script and it will convert them all.
  4.  
  5. REM Based on: http://stackoverflow.com/questions/180741/how-to-do-something-to-each-file-in-a-directory-with-a-batch-script
  6. REM Update: if the directory contains files with space in the names, you need to change the delimiter the for /f command is using. for example, you can use the pipe char.
  7.  
  8. REM %~dp0 is the directory of this bat file
  9.  
  10. SET targetdir=put_files_here
  11.  
  12. FOR /f "delims=|" %%f IN ('dir /b "%~dp0/%targetdir%"') DO (
  13. echo Converting: %%f
  14. %~dp1ffmpeg.exe -i "%targetdir%/%%f" -vn -ar 48000 -ab 192000 -ac 2 "%targetdir%/%%f.mp3"
  15. )
  16.  
  17. echo Finished
  18.  
  19. PAUSE

Report this snippet  

You need to login to post a comment.