Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Aikiman

macrumors member
Original poster
Jan 24, 2008
33
0
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?
 

Aikiman

macrumors member
Original poster
Jan 24, 2008
33
0
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.
 

pitaya

macrumors member
Jun 17, 2012
34
0
Assuming you're currently in the parent directory...

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

Aikiman

macrumors member
Original poster
Jan 24, 2008
33
0
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) :)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.