Command line method to copy all files out of a folder tree

23 07 2012

This is not so much statistics, but I do want to keep this in case I need it again.

For years I am collecting pictures and photos in a host of folders. Most pictures are in Pictures with a lot of subfolders and a lot of duplicates. Just today I imported another chunk of pictures with gThumb which has the very nice feature of creating a Year/Month/Day/ folder tree and moves the files there. But: I chose the wrong parent folder, so that I have a lot of /Year/Month/Day/ folders in more than one place. Bummer. And: this might/will happen again.

What I wanted to do is get all picture files out of all folders and sort them in one folder by name. Then have a look at the list (takes time), remove duplicates and move them back into /home/rforge/Pictures/year/month folders (for this I use gThumb, to lazy to research the find way in command line — if somebody reads this he/she might comment on that).

Anyway:
find /path/to/Pictures -name="*.jpg" -exec cp '{}' '/path/to/temporary_jpg/' ';'

finds all .jpg files in the /path/to/Pictures folder and copies (cp) them to a folder temporary_jpg in the home folder (which has to exist before running find.

Since not all files are jpg (case sensitive), like e.g. jpeg, JPEG, BMG, tiff and so on (even .mpg videos are burried in this dreadful old “Pictures” folder/dump) one can omit the -name specification and just dump everything in a flat folder sort by extension/file type and clean up:

find /path/to/Pictures -exec cp '{}' '/path/to/temporaryPics' ';'

Helpful links, which I used:

Coding Tiger
(with comments)
and for renaming all the filename salad from dozens of cameras to a consistend format, that is Year-Month-day-hour-minute-second.jpg (which I do not cover here): ak4good on ubuntu Forum (comment #6).

Advertisements

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: