[ale] Shell Scripting -> find files *.<ext> and move them to /backup

Bridges, Doug DBridges at alston.com
Thu May 6 17:54:51 EDT 2004


Close but no cigar. 
 
find / -name "*.jpg" -exec mv {} /mnt/mymachine/ \;
 
You will want to replace the first / with the directory where the current hard drive is located.  Also note that this will overwrite any files that are named the same.

-----Original Message-----
From: ale-bounces at ale.org [mailto:ale-bounces at ale.org]On Behalf Of Robert Heaven
Sent: Thursday, May 06, 2004 5:47 PM
To: Atlanta Linux Enthusiasts
Subject: Re: [ale] Shell Scripting -> find files *.<ext> and move them to /backup


I think might work:

find / -name "*.jpg" -exec mv /mnt/mymachine/ {} \;


On Thu, 2004-05-06 at 17:06, Nathan J. Underwood wrote: 

Ok, this should be an easy one, but I can't seem to remember how to do 

it.  I have a seriously dorked up Win98 workstation (won't boot) that a 

friend has given me to 'turn into linux'.  Catch is, though, he wants to 

keep all of his pictures (*.jpg, *.gif), movies (*.mpg), and documents 

(*.doc, *.xls).  I've done it before (thanks to the help of someone 

here, if I'm not terribly mistaken), and am currently perusing through 

the archives trying to find it, but need a script that'll do something 

like the following:



find all of the .jpg files, and move them to /mnt/mymachine (samba mount)

find all of the .gif files, and move them to /mnt/mymachine (samba mount)

etc.



The box is currently booted with knoppix, and I've mounted a directory 

on my box to copy the files to.  Now, I've just gotta find a relatively 

painless way to move 9,000+ files.



As a testament to how bad I am at shell scripting, I'm going to put what 

I have so far (tab #2 in my browser is at linuxdoc.org trying to get all 

the parameters right for find, exec, and copy).  As always, any help 

would be greatly appreciated.



find *.jpg -exec copy $1 /backup
  _____  

_______________________________________________

Ale mailing list

Ale at ale.org

 <http://www.ale.org/mailman/listinfo/ale> http://www.ale.org/mailman/listinfo/ale




_______________________________________________________

NOTICE:  This e-mail message and all attachments transmitted with it 
may contain legally privileged and confidential information intended 
solely for the use of the addressee.  If the reader of this message is not 
the intended recipient, you are hereby notified that any reading, 
dissemination, distribution, copying, or other use of this message or its 
attachments is strictly prohibited.  If you have received this message in 
error, please notify the sender immediately by telephone 
(404-881-7000) or by electronic mail (postmaster at alston.com), and 
delete this message and all copies and backups thereof.  Thank you.
_______________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...




More information about the Ale mailing list