You are not logged in.
Hey,
I have been looking for a way for MPD (or NCMPCPP) to add any new music I copy to my /music/ directory to a playlist, but I haven't found any way apart from using another music client.
I'm new to bash programming so I thought this might give me the opportunity to write a little script, which I run after adding each folder to the music directory:
http://pastebin.ca/1734640
I'm wondering to things: 1) How can I prevent duplicate enteries from being added to the playlist and 2) is their any other programs or tools out there that can do the same, but better, ideally being able to keep a constant watch over the /music/ directory and do this automatically.
Thanks,
JD
Last edited by kYd (2010-01-02 02:01:08)
Offline
I'm not too sure I understand. Do you want to create a play list for all your mp3 and flac files? This command would work:
find /path/to/music/ -iname "*.mp3" -o -iname "*.flac" > /path/to/playlist.m3u
If you want it updated on the fly I would just cron the above to run once ever 1 minute.
Offline
Better to run find only when the dir. is modified, even more so if the library is huge:
music_dir=/path/to/music
playlist=/path/to/playlist.m3u
[ "$music_dir" -nt "$playlist" ] &&
find "$music_dir" -type f -iname "*.mp3" -o -iname "*.flac" > $playlist
Offline
For the duplicate file thing, if mpd playlists are plaintext [they are, if I remember correctly], then you can use 'sort -u' on the file to remove duplicates, if they have the same path.
Offline
Thanks for the replies; I think I've confussed you guys a little.
I don't want to add all the current songs in the directory into a playlist, I just want to add any new songs I put into my music folder into a playlist, called "New.m3u", just so I can easily see the latest additions to my music collection.
Offline
I've written a script for this a long time ago... it uses find and ctime to locate new files in the music-dir
Files 'newer than n days' or 'older than n days' can be added.
For Example
$ ctime3u -m -1
automatically updates the DB and adds all files from the subdir 'Metal' newer than 1day to a playlist.
Playlist name can be set manually or the script creates a random one.
The new playlist can be added to the current one, or replace it.
To automate this, simply use it as a cronjob
I'll paste the script when I'm home from work
Offline
Thanks for the replies; I think I've confussed you guys a little.
I don't want to add all the current songs in the directory into a playlist, I just want to add any new songs I put into my music folder into a playlist, called "New.m3u", just so I can easily see the latest additions to my music collection.
What you want to use is inotify my friend.
Offline
I've written a script for this a long time ago
(...)
I'll paste the script when I'm home from work
damn. long workday..
< Daenyth> and he works prolifically
4 8 15 16 23 42
Offline