Skip to content

Instantly share code, notes, and snippets.

@simonthompson99
Last active January 13, 2021 12:38
Show Gist options
  • Save simonthompson99/3dc7793d007801b05c333806990997e4 to your computer and use it in GitHub Desktop.
Save simonthompson99/3dc7793d007801b05c333806990997e4 to your computer and use it in GitHub Desktop.
[rsync rename] Rsync set of files then rename #bash #file_operations
#!/bin/bash
# script to rsync then move load of files, quicker than individual scp
# usage: bash rsync_rename.sh files.txt
# where files.txt is a pipe-separated file of <remote_path>|<local_path_to_move_to>
input_file=$1
files_to_rsync=$(cut "-d|" -f1 $input_file)
echo $files_to_rsync | tr " " "\n" | rsync -arvzh --progress [email protected]:/ /tmp --files-from=-
cat $input_file | while IFS='|' read src dest; do
src="/tmp${src}"
mkdir -p "$(dirname "${dest}")"
cp $src $dest
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment