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.
Going by your path examples above with your source files being in "." and you want them copied to "../Movies":
I'm highly confident that you need to use some sort of external script wrapped around rsync to make that happen. Thus, the ultimate answer to your question is a succinct, "No."
Why don't you sync everythink not only movies (*) . If all data is synced - rsync will do nothing, if some new files appear (i.e. subtitels or movies) - they will be synced
Not nice but I ended up using the rsync option and then running
find -type d -empty -delete
to get rid of all the empty folders