LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-17-2009, 12:27 PM   #1
CQ1ST
Member
 
Registered: Oct 2005
Location: NewZealand
Distribution: Xubuntu Trusty
Posts: 77

Rep: Reputation: 18
copy sequentially please!


I've got a ch-ipod and am having problems with the order of the files (songs) in directories

so,.. how can I copy a directorys files in the Correct order please?

[edit] I've found (on my harddrive) that ls shows the mp3s ordered perfectly, but ls -f shows the 'real' situation >the mp3s are all jumbled (same in other directories too)
is there a way to mv or cp or just 're-arrange' the files alphabetically? because I'm sure that once they are in the right order the copy will go fine

Last edited by CQ1ST; 07-17-2009 at 03:44 PM.
 
Old 07-17-2009, 04:41 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 15,374

Rep: Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198Reputation: 2198
I think order is a very relevant thing. It almost never is in real file order or anything as such. Might have to pipe to other command then to what you want.
 
Old 07-19-2009, 08:45 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
The order files appear in a dir has no effect on the cp cmd.
If you REALLY need the files to be accessed in a specific order, the easiest way is to ls the filenames into a file, sorting as you go or post-facto until they are in the order you want.
Then do something like

Code:
for file in `cat file_list.txt`
do
   cmd-here
done
 
Old 03-23-2010, 07:33 PM   #4
CQ1ST
Member
 
Registered: Oct 2005
Location: NewZealand
Distribution: Xubuntu Trusty
Posts: 77

Original Poster
Rep: Reputation: 18
..the answer is:
ls -t
(shows the problem)
cd MusicToMove/
find . -print0 | sort -zr | xargs -0 cp --parents
--target-directory=/media/disk/MUSIC/FoldersMoved
(fixes the problem)

..in sort -zr, the r may be optional, I've tested this on computer, not an mpl3player just yet
 
Old 03-24-2010, 01:02 AM   #5
tommyttt
Member
 
Registered: Oct 2009
Location: Federal Way, WA
Distribution: openSUSE 11.4 x86_64, openSuSE 12.1, Fedora 15
Posts: 207

Rep: Reputation: 34
Quote:
Originally Posted by CQ1ST View Post
I've got a ch-ipod and am having problems with the order of the files (songs) in directories

so,.. how can I copy a directorys files in the Correct order please?

[edit] I've found (on my harddrive) that ls shows the mp3s ordered perfectly, but ls -f shows the 'real' situation >the mp3s are all jumbled (same in other directories too)
is there a way to mv or cp or just 're-arrange' the files alphabetically? because I'm sure that once they are in the right order the copy will go fine
PLEASE -*- do not double post. You asked the same question two (2) minutes ago.
 
Old 03-28-2010, 11:37 PM   #6
CQ1ST
Member
 
Registered: Oct 2005
Location: NewZealand
Distribution: Xubuntu Trusty
Posts: 77

Original Poster
Rep: Reputation: 18
ahh, but as you see, I just answered a 7 month old question also
 
Old 12-24-2014, 01:43 AM   #7
CQ1ST
Member
 
Registered: Oct 2005
Location: NewZealand
Distribution: Xubuntu Trusty
Posts: 77

Original Poster
Rep: Reputation: 18
the -zr is definitely not needed (it's reverse! lol)

so it's
cd /MusicToMove
find . -print0 | sort -zh | xargs -0 cp --parents
--target-directory=/media/disk/MUSIC/FoldersMoved

(the -zh there is h for human readable alpha-numeric, it means 101-120 and the 201-220 with list perfectly)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script to copy database archivelogs sequentially from one directory to another rajeshkumar.dba Programming 3 06-02-2009 09:12 AM
Newbie! How do I get background jobs to execute sequentially? Suncoast Programming 11 05-06-2009 01:31 PM
mulitple copy a existing directory and rename it at the end sequentially in BASH neo2k Linux - Newbie 2 08-20-2008 11:45 AM
moving a file sequentially to different machines nightly mijohnst Programming 3 12-04-2005 06:44 PM
boot error after using Copy Commander to copy debian system onto larger new drive Interceptor Linux - Hardware 7 05-04-2003 01:40 PM


All times are GMT -5. The time now is 07:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration