LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-08-2004, 06:10 PM   #1
amadkow
Member
 
Registered: May 2004
Location: CA, USA
Posts: 58

Rep: Reputation: 15
copying 30,000 files


I need to build a script that will move about 30,000 picture files a night(I would just wait to do it on the weekend but it would just be too many files) or so but when every I try to use the cp command it starts to copy then says there are too many arguments. Any suggestions or could I tar the files first?
 
Old 06-08-2004, 06:38 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You could use patterns to move a portion of the files at a time.

mv [a-c]*.jpg <dest-dir>/
mv [d-g]*.jpg <dest-dir>/
...
mv [S-Z]*.jpg <dest-dir>/
 
Old 06-08-2004, 06:50 PM   #3
amadkow
Member
 
Registered: May 2004
Location: CA, USA
Posts: 58

Original Poster
Rep: Reputation: 15
I tried something like that and it gives me no such directory or file
 
Old 06-08-2004, 07:47 PM   #4
J.W.
LQ Veteran
 
Registered: Mar 2003
Location: Boise, ID
Distribution: Mint
Posts: 6,642

Rep: Reputation: 87
What command specifically are you running? It sounds like your syntax is wrong, not that the number of files is large. -- J.W.
 
Old 06-09-2004, 02:43 AM   #5
crashmeister
Senior Member
 
Registered: Feb 2002
Distribution: t2 - trying to anyway
Posts: 2,541

Rep: Reputation: 47
You'll need to patch and recompile the kernel to really fix that.Nice article:
http://www.linuxjournal.com/article.php?sid=6060
I did change the kernel as it is explained there and had no problems handling up to 150.000 files after that (didn't try out for the max).

Last edited by crashmeister; 06-09-2004 at 02:45 AM.
 
Old 06-09-2004, 03:03 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
I think that the problem is that the filename expansion was too large. So it was a bash limitation and not a kernel file handling limitation.

The now such directory indicates a problem in the script that may need tweeking. Remember when using wild cards to manipulate files, that if it is possible that some of the files contain white-space characters, or characters such as '!({' that have special meaning to the shell, that you need to put the wild cards in double quotes.
cp "[a-fA-f]*.jpg" "${destdir}" for instance.
 
Old 06-09-2004, 03:29 AM   #7
pudhiyavan
Member
 
Registered: Oct 2003
Location: Linux world
Distribution: redhat,mandy,centos,debian,ubuntu
Posts: 209

Rep: Reputation: 30
how abot cp -r * destin.directory
 
Old 06-09-2004, 08:27 AM   #8
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
No, the '*' will expand and there will be too many files. That is what he tried originally.
 
Old 06-09-2004, 08:54 AM   #9
amadkow
Member
 
Registered: May 2004
Location: CA, USA
Posts: 58

Original Poster
Rep: Reputation: 15
thanks for the help. I think I will pull out my linux books today and see what I can do for a work around for now.
 
Old 06-09-2004, 09:34 AM   #10
mfeat
Member
 
Registered: Aug 2003
Location: Akron, OH
Distribution: Fedora Core 3
Posts: 185

Rep: Reputation: 30
xargs:

http://www.unixreview.com/documents/s=8274/sam0306g/

Limit the number of files sent to mv at a time by using the xargs -l option. (The xargs -i () syntax is explained later in the article). The following command sets a limit of 56 files at time, which mv receives:

find ./ -type f -print | xargs -l56 -i mv -f {} ./newdir
 
Old 06-09-2004, 12:12 PM   #11
di11rod
Member
 
Registered: Jan 2004
Location: Austin, TEXAS
Distribution: CentOS 6.5
Posts: 211

Rep: Reputation: 32
that's really cool

mfeat-

thanks for this recommendation! This will also help when you sometimes have permissions problems and other crap break a large file transfer and you can restart it without having to start from the beginning.

di11rod
 
  


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
Copying files paddyjoy Linux - Newbie 10 10-25-2013 11:12 AM
100,000,000 Firefox downloads! Eerath General 6 10-22-2005 11:20 PM
1,000,000,000 PCs by 2010 masand Linux - News 4 11-01-2004 01:55 AM
LinuxQuestions.org Surpasses 1,000,000 Posts jeremy LQ Suggestions & Feedback 15 07-21-2004 12:52 AM
Directory contains 26,000 files. How to split into sub-dirs? BrianK Linux - General 4 05-12-2004 04:37 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:06 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