daily pastebin goal
63%
SHARE
TWEET

m-TAGS generator

BlackNuller Sep 6th, 2015 (edited) 151 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @echo off
  2. @chcp 65001 >NUL
  3.  
  4. rem Recursively indexes FLAC files into a single m-TAGS [http://www.m-tags.org/] file
  5. rem You're gonna need:
  6. rem jq https://stedolan.github.io/jq/download/
  7. rem FFprobe http://sourceforge.net/projects/ffprobe/
  8. rem an empty bom.txt with the UTF-8 BOM signature
  9.  
  10. if "%~1" == "" (
  11.         echo Usage:
  12.         echo create-mtags.bat path [target.tags]
  13.         goto :eof
  14. )
  15.  
  16. SET TARGET_DIR="%~1"
  17.  
  18. if %cd:~-1%==\ (
  19.         SET CURRENT_DIR=%cd:~0,-1%
  20. ) else (
  21.         SET CURRENT_DIR=%cd%
  22. )
  23.  
  24. if not "%~2" == "" (
  25.         SET TARGET_FILE="%~2"
  26. ) else (
  27.         SET TARGET_FILE="%CURRENT_DIR%\%~nx1.tags"
  28. )
  29.  
  30. SET TMP_FILE="%TEMP%\tags.tmp"
  31.  
  32. echo.>%TMP_FILE%
  33.  
  34. for /R %TARGET_DIR% %%i in (*.flac) do (
  35.         echo %%~nxi
  36.         ffprobe -v quiet -print_format json -show_entries format=filename,duration:format_tags:format_tags "%%i" >> %TMP_FILE%
  37. )
  38.  
  39. copy /Y /B "%~dp0bom.txt" %TARGET_FILE%
  40.  
  41. jq -s ". | map({\"@\": [\"/\", .format.filename|gsub(\"[\\\\]\"; \"/\")] | add, DURATION: .format.duration } + { TRACKNUMBER: .format.tags.track, ALBUMARTIST: .format.tags.album_artist, \"ALBUM ARTIST\": .format.tags.album_artist, DISCNUMBER: .format.tags.disc } + .format.tags | del (.track, .album_artist, .disc)) | del(.[][] | select(. == null)) | unique" %TMP_FILE% >> %TARGET_FILE%
  42.  
  43. del %TMP_FILE%
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top