-
-
Save victorfontes/96002c11fbf17b8ad59cdb2e1dcca067 to your computer and use it in GitHub Desktop.
mv with progress using rsync
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # fish function | |
| function rsmv | |
| if test (count $argv) -lt 2 | |
| echo "Usage: rsmv SOURCE... DESTINATION" | |
| return 1 | |
| end | |
| set count (math (count $argv) - 1) | |
| set sources $argv[1..$count] | |
| set dest $argv[-1] | |
| # Copy with progress | |
| rsync -ah --info=progress2 --remove-source-files $sources $dest | |
| # Remove empty source dirs | |
| rsync -ah --delete $sources $dest | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| rsmv() { | |
| if [ "$#" -lt 2 ]; then | |
| echo "Usage: rsmv SOURCE... DESTINATION" | |
| return 1 | |
| fi | |
| # All args except last = sources | |
| local count=$(($# - 1)) | |
| local sources=("${@:1:$count}") | |
| local dest="${@: -1}" | |
| # Copy with progress | |
| rsync -ah --info=progress2 --remove-source-files "${sources[@]}" "$dest" | |
| # Remove empty source dirs | |
| rsync -ah --delete "${sources[@]}" "$dest" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment