How do I rsync an entire folder based on the existence of a specific file type in that folder
Posted
by
inquam
on Server Fault
See other posts from Server Fault
or by inquam
Published on 2010-12-29T18:15:30Z
Indexed on
2010/12/29
18:55 UTC
Read the original article
Hit count: 211
I have a server set up that receives movies to a folder. I then serve these movies using DLNA. But in the initial folder where they end up all kind of files end up. Pictures, music, documents etc. I thought I'd fix this by running the following script inside that folder
rsync -rvt --include='*/' --include='*.avi' --include='*.mkv' --exclude='*' . ../Movies/
This works and scans the given folder and moves all the found movies of the given extension types to the Movies
folder.
But I wonder if there is anyway to tell rsync to if a folder if found that includes a movie of the given extension types, sync the entire folder. Including other files such as .srt
.
This is to make it easier for me to get subtitles moved along with the movie.
I have a solution figured out via a script made in php (yea, I actually do most of my scripting in linux using php... just a habbit that stuck a long time ago). But if rsync can handle it from the start that would be super.
Also, I have noticed that this line of rsync actually copies all the root folders in the given folder. If no movie is in the folder it will create an empty folder. How do I prevent rsync from doing this... and saving me the trouble of deleting all folder in Movies
that are empty.
© Server Fault or respective owner