mv OR cp many files from 1 big directory with sub folders all to 1 spot?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users mv OR cp many files from 1 big directory with sub folders all to 1 spot?
# 1  
Old 04-25-2010
mv OR cp many files from 1 big directory with sub folders all to 1 spot?

Hello All. I am trying to do this from a terminal prompt on my mac....

I have 100 folders all named different things. Those 100 folders are inside ~/Desktop/Pictures directory.

Each of the 100 folders are uniquely named. The image files inside of each folder only have some similarities.

IE:
inside of ~/Desktop/Pictures/pix I have many files all structured like this:

4-1-2010-15-30-week-pix.jpg
4-1-2010-15-30-day-pix.jpg
4-2-2010-15-30-week-pix.jpg
4-2-2010-15-30-day-pix.jpg
4-3-2010-15-30-week-pix.jpg
4-3-2010-15-30-day-pix.jpg
4-4-2010-15-30-week-pix.jpg
4-4-2010-15-30-day-pix.jpg
(as you can see the names are the date, time, type and folder name)

for another example:
inside of ~/Desktop/Pictures/wed I have many files all structured like this:

4-1-2010-15-30-week-wed.jpg
4-1-2010-15-30-day-wed.jpg
4-2-2010-15-30-week-wed.jpg
4-2-2010-15-30-day-wed.jpg
4-3-2010-15-30-week-wed.jpg
4-3-2010-15-30-day-wed.jpg
4-4-2010-15-30-week-wed.jpg
4-4-2010-15-30-day-wed.jpg

And I have 100's of these folders inside of ~/Desktop/Pictures/ with the many image files inside of each folder all named like the above examples consistently through all folders


What I want to do:
Move every image with "week" and "4-3-2010" in it's file name FRM EVERY folder that contains these images. (~/Desktop/Pictures) to my desktop.

How do I say this in a unix command: "Take every image file in every folder and sub folder belonging to ~/Desktop/Pictures that has "week" and "4-3" in the file name and move OR copy those image files to the desktop" ????


Thanks so much!
# 2  
Old 04-26-2010
You have to use a find command as,

Code:
find ~/Desktop/Pictures -name '4-3*'

Try out something like the above, if it lists the file you require, then use mv or cp as required, ( concat to the above command )

Code:
-exec mv {} /to/location \;

Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to copy files/folders and show the files/folders?

Hi, So i know we use cp -r as a basic to copy folders/files. I would like this BUT i would like to show the output of the files being copied. With the amazing knowledge i have i have gone as far as this: 1) find source/* -exec cp -r {} target/ \; 2) for ObjectToBeCopied in `find... (6 Replies)
Discussion started by: Imre
6 Replies

2. Shell Programming and Scripting

Cpio all *.txt-files out of folders to just one directory

I need a hint for reading manpage (I did rtfm really) of cpio to do this task as in the headline described. I want to put all files of a certain type, lets say all *.txt files or any other format. Spread in more than hundreds of subdirectories in one directory I would like to select them and just... (3 Replies)
Discussion started by: 1in10
3 Replies

3. Shell Programming and Scripting

How to delete all the files and folders inside all the directories except some specific directory?

hi, i have a requirement to delete all the files from all the directories except some specific directories like archive and log. for example: there are following directories such as A B C D Archive E Log F which contains some sub directories and files. The requirement is to delete all the... (7 Replies)
Discussion started by: Little
7 Replies

4. Shell Programming and Scripting

Copy the files in directory and sub folders as it is to another directory.

How to copy files from one directory to another directory with the subfolders copied. If i have folder1/sub1/sub2/* it needs to copy files to folder2/sub1/sub2/*. I do not want to create sub folders in folder2. Can copy command create them automatically? I tried cp -a and cp -R but did... (4 Replies)
Discussion started by: santosh2626
4 Replies

5. UNIX for Dummies Questions & Answers

[SOLVED] Delete files and folders under given directory

I have a requirement to delete the files and folders under a given directory. my directory structure is like this.. Data | A(Directory) |_PDF(Directory)----pdf files |_XML()Directory --xml files |--files | B(Directory) |_PDF(Directory)----pdf files |_XML()Directory --xml files ... (1 Reply)
Discussion started by: ramse8pc
1 Replies

6. UNIX for Dummies Questions & Answers

Searching for folders/parent folders not files.

Hello again, A little while back I got help with creating a command to search all directories and sub directories for files from daystart of day x. I'm wondering if there is a command that I've overlooked that may be able to search for / write folder names to an output file which ideally... (2 Replies)
Discussion started by: Aussiemick
2 Replies

7. UNIX for Dummies Questions & Answers

Empty Directory, big size

Hello, Can somebody please explain why I have EMPTY directories on HP-UX with BIG SIZE ? Thank you ! Double post, continued here (0 Replies)
Discussion started by: drbiloukos
0 Replies

8. AIX

Fastest way to count big amount of files in sub directory

Hi, what happened is we want to count all the files in a directory and inside this directory got many folders and so take long time to count it. Already run for about few minutes but still not done. The command we use to count is find . -type f | wc -l Just wondering if there is any other... (9 Replies)
Discussion started by: ngaisteve1
9 Replies

9. HP-UX

Processing very big directory

Hello, I have a very big directory with lots of small files. Just doing a single "ls" takes eternity, so I even can't know how many files the directory has. I need to get the newest files in the last 15 minutes, but I can't get an eficient way of doing it. I've tried find, perl, shell script,... (4 Replies)
Discussion started by: psimoes79
4 Replies
Login or Register to Ask a Question