feat(user/mp4_make480.sh):Add script to convert video to 480 res
[BK-2020-03.git] / user / rsync_tranches.sh
index 7be12ad8d6f72c0a3d3bc2de1bd0bea86a0d3bec..bcae90e2db8c17a89f4f287b9a7ef7323f3ea6b8 100644 (file)
@@ -7,7 +7,7 @@ function rsync_tranches() {
     # Desc: Runs rsync in parallel across different files size ranges
     # Example: rsync_tranches -avu --progress --dry-run ./SOURCE/ ./DEST/
     # Depends: rsync 3.2.7
-    # Version: 0.0.2
+    # Version: 0.1.1
     local -a rsync_opts=();
     local source dest;
 
@@ -20,7 +20,13 @@ function rsync_tranches() {
                 shift;
                 ;;
             *)
-                if [ -z "$source" ]; then
+                ## If not a file or directory, assume option
+                if [[ ! -f "$1" ]] && [[ ! -d "$1" ]]; then
+                    rsync_opts+=("$1");
+                    shift;
+                fi;
+                ## If valid file or directory, assume source or dest path
+                if [[ -z "$source" ]]; then
                     source="$1";
                 else
                     dest="$1";
@@ -38,16 +44,44 @@ function rsync_tranches() {
 
     # Tranche 1: 0 to 1MiB-1
     rsync --min-size='0' --max-size='1MiB-1' "${rsync_opts[@]}" "$source" "$dest" &
+    sleep 2;
+
+    # Tranche 2: 1MiB to 2MiB-1
+    rsync --min-size='1MiB' --max-size='2MiB-1' "${rsync_opts[@]}" "$source" "$dest" &
+
+    # Tranche 3: 2MiB to 4MiB-1
+    rsync --min-size='2MiB' --max-size='4MiB-1' "${rsync_opts[@]}" "$source" "$dest" &
+
+    # Tranche 4: 4MiB to 8MiB-1
+    rsync --min-size='4MiB' --max-size='8MiB-1' "${rsync_opts[@]}" "$source" "$dest" &
+
+    # Tranche 5: 8MiB to 16MiB-1
+    rsync --min-size='8MiB' --max-size='16MiB-1' "${rsync_opts[@]}" "$source" "$dest" &
 
-    # Tranche 2: 1MiB to 10MiB-1
-    rsync --min-size='1MiB' --max-size='10MiB-1' "${rsync_opts[@]}" "$source" "$dest" &
+    # Tranche 6: 16MiB to 32MiB-1
+    rsync --min-size='16MiB' --max-size='32MiB-1' "${rsync_opts[@]}" "$source" "$dest" &
 
-    # Tranche 3: 10MiB to 100MiB-1
-    rsync --min-size='10MiB' --max-size='100MiB-1' "${rsync_opts[@]}" "$source" "$dest" &
+    # Tranche 7: 32MiB to 64MiB-1
+    rsync --min-size='32MiB' --max-size='64MiB-1' "${rsync_opts[@]}" "$source" "$dest" &
 
-    # Tranche 4: Greater than 100MiB
-    rsync --min-size='100MiB' --max-size='8192PiB-1' "${rsync_opts[@]}" "$source" "$dest" &
+    # Tranche 8: 64MiB to 128MiB-1
+    rsync --min-size='64MiB' --max-size='128MiB-1' "${rsync_opts[@]}" "$source" "$dest" &
+
+    # Tranche 9: 128MiB to 256MiB-1
+    rsync --min-size='128MiB' --max-size='256MiB-1' "${rsync_opts[@]}" "$source" "$dest" &
+
+    # Tranche 10: 256MiB to 512MiB-1
+    rsync --min-size='256MiB' --max-size='512MiB-1' "${rsync_opts[@]}" "$source" "$dest" &
+
+    # Tranche 11: 512MiB to 1024MiB-1
+    rsync --min-size='512MiB' --max-size='1024MiB-1' "${rsync_opts[@]}" "$source" "$dest" &
+
+    # Tranche 12: Greater than 1024MiB
+    rsync --min-size='1024MiB' --max-size='8192PiB-1' "${rsync_opts[@]}" "$source" "$dest" &
 
     wait # Wait for all rsync processes to complete
 };
 export -f rsync_tranches;
+
+# Author: Steven Baltakatei Sandoval
+# License: GPLv3+