Skip to content

Instantly share code, notes, and snippets.

@victorfontes
Last active September 14, 2025 08:34
Show Gist options
  • Select an option

  • Save victorfontes/96002c11fbf17b8ad59cdb2e1dcca067 to your computer and use it in GitHub Desktop.

Select an option

Save victorfontes/96002c11fbf17b8ad59cdb2e1dcca067 to your computer and use it in GitHub Desktop.
mv with progress using rsync
# 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
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