Skip to content

Instantly share code, notes, and snippets.

@veebch
Last active November 16, 2024 23:56
Show Gist options
  • Save veebch/e925cbd977ee205c0e495c98a2791352 to your computer and use it in GitHub Desktop.
Save veebch/e925cbd977ee205c0e495c98a2791352 to your computer and use it in GitHub Desktop.
A single command to invoke a fzf interface that generates playlists from a subset of music added to a directory in the last 10 days
# Find directories in music folder modified in last 240 hours
fd . '/path/to/music/' \
--changed-within "240h" \
--min-depth 2 \
-d 2 \
| \
# Remove any paths containing @ symbol (Synology NAS quirk)
rg -v '@' \
| \
sed "s|/path/to/music/||" \
| \
# Interactive fuzzy selection with multi-select enabled
fzf --multi \
| \
# For each selected directory, find MP3/FLAC files
xargs -I{} fd . "/path/to/music/{}" \
-type f \
\( -iname "*.mp3" -o -iname "*.flac" \) \
-print0 \
| \
# Sort the null-terminated file list
sort -z \
| \
# Convert null bytes to proper newlines using sed
sed 's/\x0/\n/g' > /path/to/playlists/newmusic.m3u
@veebch
Copy link
Author

veebch commented Nov 10, 2024

This relies on a music directory that is structured {Artist}/{Album}/{Tracks}. Tested with mpd and ncmpcpp
Here it is running: https://www.threads.net/@v_e_e_b/post/DCO1A4vxj6j?xmt

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