Regex find and copy in bash (preserving folder structure)?
- by Jonathan Sternberg
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?