You are not logged in.
Got an Audacious playlist MyMusic.m3u that lists about 500 wav files on my file server line by line. Is there an easy way to copy these wav's to a USB device?
Thanks, rolfie
Last edited by rolfie (2021-04-30 12:32:59)
Offline
Thanks for your suggestion, but the MyMusic.m3u file isn't accepted as input for the copy operation. Here are 3 lines as they appear in the file:
/srv/Audio/CDs/Adele - Adele21/Adele - Rolling in the deep.wav
/srv/Audio/CDs/Adele - Adele21/Adele - Set fire to the rain.wav
/srv/Audio/CDs/Adele - Adele21/Adele - Someone like you.wav
....
Or is is the only way to write a script that uses the file as input line by line?
rolfie
Last edited by rolfie (2021-04-30 12:39:21)
Offline
EDIT: I forgot the m3u ...
find /srv/Audio/CDs -name \*.wav -o -name \*.m3u -print0 | xargs -0 cp -t /media/usb_device
or perhaps
find /srv/Audio/CDs -type f -print0 | xargs -0 cp -t /media/usb_device
Offline
so what is the base directory, is it /srv/Audio/ for all 500 .wavs files and directories? Looks like you need to recurse into the many artists and album directories. Maybe tree the /srv/Audio/ directory to see what you have there?
tree /srv/Audio/
Last edited by dice (2021-04-30 12:55:51)
Offline
EDIT: I forgot the m3u ...
find /srv/Audio/CDs -name \*.wav -o -name \*.m3u -print0 | xargs -0 cp -t /media/usb_device
or perhaps
find /srv/Audio/CDs -type f -print0 | xargs -0 cp -t /media/usb_device
That second command does the job nicely.
Offline
The playlist is a selection of *.wav files, grown over the years from a Winamp playlist under Windows. On the server I have stored all the ripped CDs I own, one directory per CD. And yes, the paths and file names contain whitespaces and special characters all over. I don't want to copy every single file but just the ones listed in the playlist. And about 500 files manually ......
rolfie
Offline
To clarify a bit more having sort of understood what you want, rsync is your tool here.
Have a look at this.
Offline
My intention is just to copy the files listed in the playlist, and not all the CDs from the server. Simple reason being space available.
Thanks for the link to Stackexchange. At first sight rsync looks promising, at least it might allow for using the specs in the m3u file. I have started to fiddle with the example given there and tried to adapt it to my needs. But its not exactly going as I would expect.
As a start I have reduced the list of files to be copied to 3 to be able to test the options. And I have prepared an empty space on a drive on my workstation. I have left out the sed stuff, since the 3 test files just contain a lot of spaces. Thought that should work. Something still isn't right.
~/Musik$ rsync -a --include-from=/home/rolf/Musik/Test.m3u --include='*/' --exclude='*' /srv/Audio/ /mnt/Daten/rolf/Audio --progress --prune-empty-dirs
building file list ...
403 files to consider
./
~/Musik$ rsync -a --files-from=/home/rolf/Musik/Test.m3u --include='*/' --exclude='*' /srv/Audio/ /mnt/Daten/rolf/Audio --progress --prune-empty-dirs
building file list ...
rsync: link_stat "/srv/Audio/srv/Audio/CDs/Adele - Adele21/Adele - Rolling in the deep.wav" failed: No such file or directory (2)
rsync: link_stat "/srv/Audio/srv/Audio/CDs/Adele - Adele21/Adele - Set fire to the rain.wav" failed: No such file or directory (2)
rsync: link_stat "/srv/Audio/srv/Audio/CDs/Adele - Adele21/Adele - Someone like you.wav" failed: No such file or directory (2)
0 files to consider
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1207) [sender=3.1.3]
~/Musik$ rsync -a --files-from=/home/rolf/Musik/Test.m3u --include='*/' --exclude='*' / /mnt/Daten/rolf/Audio --progress --prune-empty-dirs
building file list ... 0 files to consider
~/Musik$ rsync -a --files-from=/home/rolf/Musik/Test.m3u --include='*/' --exclude='*' // /mnt/Daten/rolf/Audio --progress --prune-empty-dirs
building file list ... 0 files to consider
Any idea what not right?
rolfie
Offline
Try
while IFS= read -r line ; do cp -- "$line" /media/usb_device ; done < /home/rolf/Musik/Test.m3u
Reference: https://mywiki.wooledge.org/BashFAQ/001
EDIT: added -- to the cp command to accommodate filenames that start with -.
Last edited by Head_on_a_Stick (2021-05-01 07:05:24)
Brianna Ghey — Rest In Power
Offline
@HOAS: thanks for that simple bash line, it did the job. 470 files and 19G of data have been copied.
That link yyou posted looks interesting, more examples than the Advanced Scripting Guide I tried to work with. Is bookmarked.
Everybody have a nice weekend.
rolfie
Last edited by rolfie (2021-04-30 19:34:11)
Offline
head on a stick nailed it.
I did a test with rsync and this is how i went about it, although i would probably stick with the bash command from head on a stick.
first created a dummy directory for testing.
~$ tree audio/
audio/
└── cds
├── 1
│ └── 1.mp3
├── 2
│ └── 2.mp3
├── 3
│ └── 3.mp3
└── 4
5 directories, 3 files
then created my playlist.m3u
find /home/dice/audio/cds/ -type f -iname "*.mp3" > playlist.m3u
the contents of playlist.m3u
/home/dice/audio/cds/2/2.mp3
/home/dice/audio/cds/3/3.mp3
/home/dice/audio/cds/1/1.mp3
then added a random directory number 5 not on the playlist.
~$ tree audio/
audio/
└── cds
├── 1
│ └── 1.mp3
├── 2
│ └── 2.mp3
├── 3
│ └── 3.mp3
├── 4
└── 5
└── 5.mp3
6 directories, 4 files
created test directory for the rsync.
/home/dice/test-usb-dir
now the rsync command.
rsync -a --include-from=/home/dice/playlist.m3u --delete --delete-excluded --prune-empty-dirs /home/dice/audio test-usb-dir/
edit: this command is better
rsync -av --relative $(cat ~/playlist.m3u) test-usb-dir/
result
~$ tree test-usb-dir/
test-usb-dir/
└── home
└── dice
└── audio
└── cds
├── 1
│ └── 1.mp3
├── 2
│ └── 2.mp3
└── 3
└── 3.mp3
7 directories, 3 files
this seems to work for me and I will test this with some actual audio files in music directory soon.
Last edited by dice (2021-05-01 13:05:56)
Offline