How do I rsync an entire folder based on the existence of a specific file type in that folder
- by inquam
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.