Copying jpegs recursively while preserving the directory structure
So I have a bunch of directories:
dir1 dir2 dir3 etc. which themselves all contain subdirectories: dir1 subdir1 subdir2 etc.and at the lowest level they contain all of these jpegs that I need. The problem is that I only need some of them. They're named like this: pic1.jpg pic1_med.jpg pic1_small.jpg pic2.jpg pic2_med.jpg etc. I want to just grab the ones without the size suffix and copy them all to another set of folders, while preserving the directory structure. The numbering all starts at 1 for each low level subdirectory, so I think that the directory structure is the only way to not get them mixed up. I know that cp has a recursive option -r but how do I just extract the ones without the underscore? And then how do I preserve the directory structure when I move them over? |
find
Code:
find . -type f -regextype posix-extended -regex ".*pic[0-9]+\.jpg" -exec cp -p --parents "{}" /TARGET/PATH/ \; I tested it - and it works for me - but as with anything free, no guarantee! Cheers, Sasha PS - I encourage you to read the manpages for `cp` and `find` and understand the options I used. |
All times are GMT -5. The time now is 03:57 AM. |