Skip to content

Instantly share code, notes, and snippets.

@TatsuyaOGth
Created December 19, 2021 12:03
Show Gist options
  • Select an option

  • Save TatsuyaOGth/386d69f5d93258b6be51adee4b809200 to your computer and use it in GitHub Desktop.

Select an option

Save TatsuyaOGth/386d69f5d93258b6be51adee4b809200 to your computer and use it in GitHub Desktop.
#!/bin/sh
# can additional arguments
# ex.: $ sh rsync_tool.sh --checksum
echo "Input source directory path (no need end slash)"
read SRC
echo "Input destination directory path (no need end slash)"
read DST
echo "Input include file type (ex. '*.JPG')"
read INC
echo "- Source: ${SRC}"
echo "- Dstination: ${DST}"
echo "- Include file type: ${INC}"
echo "- Custom arguments: $1"
echo "=> Rsync dry run"
rsync $1 -avzn --exclude=".*" --include="${INC}" --exclude="*" "${SRC}/" "${DST}/"
read -p "ok? (y/N):" yn
case "$yn" in [yY]*) ;; *) echo "abort." ; exit ;; esac
rsync $1 -avz --progress --exclude=".*" --include="${INC}" --exclude="*" "${SRC}/" "${DST}/"
echo "Done!"
read -p "Any key to close"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment