Regex find and copy in bash (preserving folder structure)?
Posted
by Jonathan Sternberg
on Stack Overflow
See other posts from Stack Overflow
or by Jonathan Sternberg
Published on 2010-05-15T06:11:41Z
Indexed on
2010/05/15
6:14 UTC
Read the original article
Hit count: 347
I have a folder with a bunch of log files. Each set of log files is in a folder detailing the time and date that the program was run. Inside these log folders, I've got some video files that I want to extract. All I want is the video files, nothing else. I tried using this command to only copy the video files, but it didn't work because a directory didn't exist.
.rmv is the file extension of the files I want.
$ find . -regex ".*.rmv" -type f -exec cp '{}' /copy/to/here/'{}'
If I have a folder structure such as:
|- root
|
|--- folder1
|
|----- file.rmv
|
|--- folder2
|
|----- file2.rmv
How can I get it to copy to copy/to/here with it copying the structure of folder1 and folder2 in the destination directory?
© Stack Overflow or respective owner