Skip to content

Instantly share code, notes, and snippets.

@yuchenlin
Last active April 22, 2021 02:13
Show Gist options
  • Save yuchenlin/08134f5779b34dade090d9e33a2e9d4b to your computer and use it in GitHub Desktop.
Save yuchenlin/08134f5779b34dade090d9e33a2e9d4b to your computer and use it in GitHub Desktop.
`mv` a folder with a progress bar and detailed logs.
#!/bin/bash
# Usage: bash mv.sh /path/to/src/ /path/to/target/
sourcedir=$1
targetdir=$2
filecount=$(find $sourcedir | wc -l)
echo $filecount # Print the number of the total files.
mkdir $targetdir
mv -v $sourcedir $targetdir | pv -l -s $filecount > /tmp/mv_log.txt
@yuchenlin
Copy link
Author

yuchenlin commented Apr 22, 2021

The command will show a progress bar and ETA for the overall movement. You can check /tmp/mv_log.txt for a detailed list of moved files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment