[opensuse] forcing order of file copy
Hello: I have an MP3 player that plays the files according to order their were saved on the flash drive (practically according to their index numbers). When I copy the files onto the flash drive the order of the copy not always occurs alphabetically. Eg. copying of 04.mp3 may precede copying of 03.mp3. I tried command line cp, rsync, krusader in kde. When I copy several albums to a card the order of songs frequently messed up. How could I force copy to take place in alphabetical order in linux? TIA, IG ______________________________________________________________________ Digitális fényképezőgépek, videokamerák, notebookok, mobiltelefonok, navigációk, LCD TV-k és monitorok széles választéka a FotoMarket áruházban! - www.fotomarket.hu -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Istvan Gabor schreef:
Hello:
I have an MP3 player that plays the files according to order their were saved on the flash drive (practically according to their index numbers). When I copy the files onto the flash drive the order of the copy not always occurs alphabetically. Eg. copying of 04.mp3 may precede copying of 03.mp3. I tried command line cp, rsync, krusader in kde. When I copy several albums to a card the order of songs frequently messed up.
How could I force copy to take place in alphabetical order in linux?
In the directory of the mp3 files (bash shell):
for file in *mp3; do cp $file
Jos van Kan
You can check for yourself that this gets them in alphabetical order by:
for file in *mp3; do echo $file; done
Regards, -- Jos van Kan registered Linux user #152704
Thanks Jos. In the meantime I found a program called FATSort Utility which does exactly what I need. It can be found at: http://fatsort.berlios.de/ The only drawback is you have to run it as root since it operates with the unmounted flash card directly. Regarding the solution you gave: it works with one directory at a time. What is if you have several directories and don't want to create and fill them individually? TIA, IG ______________________________________________________________________ Digitális fényképezőgépek, videokamerák, notebookok, mobiltelefonok, navigációk, LCD TV-k és monitorok széles választéka a FotoMarket áruházban! - www.fotomarket.hu -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday, 2008-11-14 at 11:30 +0100, Istvan Gabor wrote:
In the meantime I found a program called FATSort Utility which does exactly what I need. It can be found at: http://fatsort.berlios.de/ The only drawback is you have to run it as root since it operates with the unmounted flash card directly.
Maybe you can try with the old command line norton utilities (1985-1995). I seem to recall a dir sort utility there. And obviously, they work on mounted volumes; hopefully they'll work under wine or dosemu. And I think old versions were given free on magazines much later on, so perhaps it is possible to obtain them free, too.
Regarding the solution you gave: it works with one directory at a time. What is if you have several directories and don't want to create and fill them individually?
Maybe you could do it with 'mc'. - -- Cheers, Carlos E. R. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) iEYEARECAAYFAkkdYOQACgkQtTMYHG2NR9Xk6QCcDmlWxtudlE9JvGnIgHGZrrwP MJUAniVnQ/Cy/RBBYzYBilBTYxASd+Rp =1+s0 -----END PGP SIGNATURE----- -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Istvan Gabor wrote:
Regarding the solution you gave: it works with one directory at a time. What is if you have several directories and don't want to create and fill them individually?
Assuming that your music is stored in ~/mp3 and your MP3-player is mounted at /media/disk, you can use cd ~/mp3 find . -print0 | sort -z | xargs -0 cp --parents --target-directory=/media/disk Which will copy all files and directories in ~/mp3 recursively in alphabetical order and put them in /media/disk. Alphabetical order also regarding directory names, so ~/mp3/Abba/ will be copied before ~/mp3/ZZ_Top/. Regards nordi -- Spam protection: All mail to me that does not contain the string "suse" goes to /dev/null. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
----- Original Message -----
From: "nordi"
Istvan Gabor wrote:
Regarding the solution you gave: it works with one directory at a time. What is if you have several directories and don't want to create and fill them individually?
Assuming that your music is stored in ~/mp3 and your MP3-player is mounted at /media/disk, you can use
cd ~/mp3 find . -print0 | sort -z | xargs -0 cp --parents --target-directory=/media/disk
Which will copy all files and directories in ~/mp3 recursively in alphabetical order and put them in /media/disk. Alphabetical order also regarding directory names, so ~/mp3/Abba/ will be copied before ~/mp3/ZZ_Top/.
Regards nordi
Nice. So never mind the thing I just posted. This is the same idea except he found fancy options for "cp" that do all the stuff I was doing in the mycpy script. -- Brian K. White brian@aljex.com http://www.myspace.com/KEYofR +++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++. filePro BBx Linux SCO FreeBSD #callahans Satriani Filk! -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
----- Original Message -----
From: "Istvan Gabor"
You can check for yourself that this gets them in alphabetical order by:
for file in *mp3; do echo $file; done
Regards, -- Jos van Kan registered Linux user #152704
Thanks Jos. In the meantime I found a program called FATSort Utility which does exactly what I need. It can be found at: http://fatsort.berlios.de/ The only drawback is you have to run it as root since it operates with the unmounted flash card directly. Regarding the solution you gave: it works with one directory at a time. What is if you have several directories and don't want to create and fill them individually? --------- kinda kludgy what with needing to write a little script and having to cd to a particular spot to work from and all, but... Well, your need is weird, so of course no tools have nice options built in for that to make nice elegant solution, so we have to brute force it. # Step 1: create a small script that takes a single argument # and copies that file to the usb drive, preserving relative paths vi ~/bin/mycpy: ----top---- #!/bin/sh # usb stick mount point # USB=/media/VOLUME etc... USB=/mnt/sdb R="${1#*/}" mkdir -p "${USB}/${R%/*}" >/dev/null 2>&1 cp -f "$R" "${USB}/${R##*/}" ---end--- # Now make the script executable chmod 755 ~/bin/mycpy # Above you just do one time. From now on you do this to run: # cd to the top level where your mp3's are cd /shared/tunes # use find to generate a file listing # use sort to sort # use xargs to perform an action (mycpy) once for each file. # use null-terminate option for all 3 utils to handle filenames robustly find ./ ! -type d -print0 |sort -z |xargs -0rn 1 mycpy That find syntax will find all files that aren't directories because most of my tunes are .ogg and many are .wma and only some are .mp3 Also I don't want to have to care about up/low/mixed case. Also my player can actually use the folder.jpg's You could instead collect just mp3's this way: find ./ -name '*.mp3' -print0 |sort -z |xargs -0rn 1 mycpy Don't copy these command visually, use cut & paste. single-forward-quote is different from backtick and double-quote, and zero is different from oh. So, I said it was kludgy, but even so, here are the advantages: * There is no globbing used anywhere (even '*.mp3' isn't globbing, as it's in single-quotes, so it's merely a pattern match expression that find will use, not something the shell will try to expand into some huge list. This means that this does not care how many files you have, nor how many directories. * Correctly handles most files that have "bad" characters. spaces and most other characters are ok, not sure about double-quotes. mycpy will generate commands like this as it runs: [...] mkdir -p "/mnt/sdb/Anderson, Bruford, Wakeman, Howe/Anderson, Bruford, Wakeman, Howe" >/dev/null 2>&1 cp -f "Anderson, Bruford, Wakeman, Howe/Anderson, Bruford, Wakeman, Howe/08 - Order Of The Universe (i. Order Theme, ii. Rock Gives Courage, iii. It's So Hard To Grow, iv. The Universe).ogg" "/mnt/sdb/08 - Order Of The Universe (i. Order Theme, ii. Rock Gives Courage, iii. It's So Hard To Grow, iv. The Universe).ogg" mkdir -p "/mnt/sdb/Anderson, Bruford, Wakeman, Howe/Anderson, Bruford, Wakeman, Howe" >/dev/null 2>&1 cp -f "Anderson, Bruford, Wakeman, Howe/Anderson, Bruford, Wakeman, Howe/09 - Let's Pretend.ogg" "/mnt/sdb/09 - Let's Pretend.ogg" mkdir -p "/mnt/sdb/Anderson, Bruford, Wakeman, Howe/Anderson, Bruford, Wakeman, Howe" >/dev/null 2>&1 cp -f "Anderson, Bruford, Wakeman, Howe/Anderson, Bruford, Wakeman, Howe/folder.jpg" "/mnt/sdb/folder.jpg" mkdir -p "/mnt/sdb/Apocalyptica/Amplified A Decade of Reinventing the Cello (disc 1)" >/dev/null 2>&1 cp -f "Apocalyptica/Amplified A Decade of Reinventing the Cello (disc 1)/01. Enter Sandman.ogg" "/mnt/sdb/01. Enter Sandman.ogg" mkdir -p "/mnt/sdb/Apocalyptica/Amplified A Decade of Reinventing the Cello (disc 1)" >/dev/null 2>&1 cp -f "Apocalyptica/Amplified A Decade of Reinventing the Cello (disc 1)/02. Harmageddon.ogg" "/mnt/sdb/02. Harmageddon.ogg" [...] Ridiculously long lines intentionally left unwrapped, since the point is to try to show exactly what the script will do. In this case the single quotes in "It's So Hard To Grow" and "Let's Pretend" would be handled just fine , as well as all that other garbage. We are ignoring the messages from mkdir because most of the time it will spew a "already exists" error message which we don't care about. -- Brian K. White brian@aljex.com http://www.myspace.com/KEYofR +++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++. filePro BBx Linux SCO FreeBSD #callahans Satriani Filk! -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (5)
-
Brian K. White
-
Carlos E. R.
-
Istvan Gabor
-
Jos van Kan
-
nordi