Terminal - move all files named... - MacRumors Forums
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

Similar Threads
thread Thread Starter Forum Replies Last Post
Open all files from folder via Terminal vloryan Mac Programming 11 Jan 12, 2014 05:55 PM
Use Terminal to move between dirs on Network Storage TallDoug Mac Applications and Mac App Store 2 Feb 8, 2013 10:22 AM
Hidden files in Terminal ruqui OS X 18 Feb 5, 2013 02:24 AM
Accidentally quit terminal and files are gone directeur Mac Basics and Help 1 Jan 26, 2013 11:18 PM
How to look at files in Terminal? s97fever Mac Basics and Help 3 Jan 22, 2013 04:50 PM

Forum Jump

All times are GMT -5. The time now is 07:24 PM.

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

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