Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Mac OS X > How do I write a shell script which copies all files of the same type

How do I write a shell script which copies all files of the same type
Thread Tools
Mac Enthusiast
Join Date: Oct 2000
Location: Toronto
Status: Offline
Reply With Quote
Jun 6, 2006, 12:54 AM
 
Hello,


I want a simple script which when run will copy all files of a certain type within a volume (and all the files of this type in the directories and all subdirectories)... to another directory.

Any help is appreciated.
     
Grizzled Veteran
Join Date: Mar 2004
Status: Offline
Reply With Quote
Jun 6, 2006, 05:22 PM
 
Originally Posted by anothermacguy
all files of a certain type
You might need to elaborate on that part a bit.

Let's say we can use the extension... maybe to grab jpegs?

find -x /path/to/source/folder -iname "*.jpg" -print0 |
xargs -0 -n1 -I% cp % /path/to/target/folder

...might work.
-HI-
     
Mac Enthusiast
Join Date: Oct 2000
Location: Toronto
Status: Offline
Reply With Quote
Jun 6, 2006, 09:39 PM
 
Thanks Hal, I thought about it a bit more and the folder structure was always goiing to be the same, so I just used cp intstead. Thanks a lot though, I'm going to use this at sometime I'm sure.
     
   
Thread Tools
Forum Links
Forum 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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:05 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2