Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- @chcp 65001 >NUL
- rem Recursively indexes FLAC files into a single m-TAGS [http://www.m-tags.org/] file
- rem You're gonna need:
- rem jq https://stedolan.github.io/jq/download/
- rem FFprobe http://sourceforge.net/projects/ffprobe/
- rem an empty bom.txt with the UTF-8 BOM signature
- if "%~1" == "" (
- echo Usage:
- echo create-mtags.bat path [target.tags]
- goto :eof
- )
- SET TARGET_DIR="%~1"
- if %cd:~-1%==\ (
- SET CURRENT_DIR=%cd:~0,-1%
- ) else (
- SET CURRENT_DIR=%cd%
- )
- if not "%~2" == "" (
- SET TARGET_FILE="%~2"
- ) else (
- SET TARGET_FILE="%CURRENT_DIR%\%~nx1.tags"
- )
- SET TMP_FILE="%TEMP%\tags.tmp"
- echo.>%TMP_FILE%
- for /R %TARGET_DIR% %%i in (*.flac) do (
- echo %%~nxi
- ffprobe -v quiet -print_format json -show_entries format=filename,duration:format_tags:format_tags "%%i" >> %TMP_FILE%
- )
- copy /Y /B "%~dp0bom.txt" %TARGET_FILE%
- 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%
- del %TMP_FILE%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement