LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 11:27 AM   #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 02:44 PM.
 
Old 07-17-2009, 03:41 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 22,001

Rep: Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629Reputation: 3629
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, 07:45 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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, 06: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, 12: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, 10: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, 12: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



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 08:12 AM
Newbie! How do I get background jobs to execute sequentially? Suncoast Programming 11 05-06-2009 12:31 PM
mulitple copy a existing directory and rename it at the end sequentially in BASH neo2k Linux - Newbie 2 08-20-2008 10:45 AM
moving a file sequentially to different machines nightly mijohnst Programming 3 12-04-2005 05:44 PM
boot error after using Copy Commander to copy debian system onto larger new drive Interceptor Linux - Hardware 7 05-04-2003 12:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:32 PM.

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
Open Source Consulting | Domain Registration