Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Nov 13, 2012, 02:42 PM   #1
Aikiman
macrumors member
 
Join Date: Jan 2008
Terminal - move all files named...

I have a whole lot of files that exist in their own directories which in turn exist in a parent directory that I have to copy and move into another directory. Is there a way in terminal that will enable me to look in all the directories inside my current one, search for all files with specified string and wildcard, copy and move into specified directory?
__________________
newbie programmer alert.
Aikiman is offline   0 Reply With Quote
Old Nov 13, 2012, 02:44 PM   #2
balamw
Moderator
 
balamw's Avatar
 
Join Date: Aug 2005
Location: New England, USA
find can do all of that.

http://unixhelp.ed.ac.uk/CGI/man-cgi?find

You'd need to be more specific if you want more help.

B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme
balamw is offline   0 Reply With Quote
Old Nov 13, 2012, 02:58 PM   #3
Aikiman
Thread Starter
macrumors member
 
Join Date: Jan 2008
Thanks for the fast reply

Okay, Inside my current directory I have over 100 child directories. Inside these child directories I have many files but the ones I only need to worry about have a prefix 'ANZ1155...' the rest of the text is unique to the file. I want to be able to make a copy of these files and move them to another directory. I want to be able to do this in one go - so find ALL files with 'ANZ1155' prefix inside child directories, copy and move copies to specified path.

Hope that is clear.
__________________
newbie programmer alert.
Aikiman is offline   0 Reply With Quote
Old Nov 13, 2012, 03:29 PM   #4
pitaya
macrumors member
 
Join Date: Jun 2012
Assuming you're currently in the parent directory...

Code:
find . -type f -name ANZ1155\* -exec cp {} ../destination/ \;
pitaya is offline   0 Reply With Quote
Old Nov 13, 2012, 03:49 PM   #5
Aikiman
Thread Starter
macrumors member
 
Join Date: Jan 2008
Quote:
Originally Posted by pitaya View Post
Assuming you're currently in the parent directory...

Code:
find . -type f -name ANZ1155\* -exec cp {} ../destination/ \;

That works, thanks a lot guys. (Now I will dissect the code and learn it)
__________________
newbie programmer alert.
Aikiman is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump


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

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC