I'm just putting here this command to remember it next time when I need it.
Problem to be solved
When SD card of my photo camera is full I just upload the photos to my NAS server NSA320 . After that usually I do some cleanup and one of the steps is to move the video (there are not only photos) files from the the photo/ directory to other location.
Until now I did this step manually, to save time I was thinking to make it automatic.
This is what I want to do:
- Get shell access on my NSA320 , to do this I've installed ffp (Fonz fun_plug). It is a collection of packages for NSA320 that includes a ssh server.
- After geting ssh access in step 1, I need to create a small scrip to move all the video files from $SOURCE_DIR to $DST_DIR. All video means files with next extensions:
- .MOV (has to be no case sensitive)
- .MPG/MP4 (has to be no case sensitive)
- .AVI (has to be no case sensitive)
I'm using rsync command.
The meaning of the arguments:
- -r = to go recursively on the entire $SOURCE_DIR
- -a = archive mode, it means to preserve most of the attributes of the files. For me important was last modified time
- -v = verbose; I just wanted to have a list with files that have been moved.
- --remove-source-files = to remove from source dir the files that have been copied to destination.
- --exclude '*' = by default exclude all files; except the one passed to "--include" switches
- --include '*/' = include directories in teh list of files that have to be moved
- --include '*.[Mm][Oo][Vv]' = include files with .MOV extension; no case sensitive. Similar for .MPG, .MP4, .AVI
- --prune-empty-dirs = do not copy empty dirs from source to destination
At the end of the command you will noticed something like this:
sent 24287985339 bytes received 8458 bytes 12766356.79 bytes/sec
total size is 24511383985 speedup is 1.01
On my NSA320 it took few minutes to move ~23GB.