Home » Questions » Computers [ Ask a new question ]

How do I copy specific set of files in one directory structure to another?

How do I copy specific set of files in one directory structure to another?

Say I've got a directory structure somewhat like this:

Asked by: Guest | Views: 156
Total answers/comments: 1
bert [Entry]

"You can use find combined with the passthrough feature of cpio for that. Something like this:

find old_dir -name ""file_001.jpg"" -print | cpio -pd new_dir

The -p flag on cpio triggers passthrough mode, which effectively just copies files from their original location to new_dir. The -d flag creates all the necessary directories, so you'll have the same heirarchy under new_dir as you had under old_dir (at least, so far as directories containing file_001.jpg are concerned)."