mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

updir (784B)


      1 #!/bin/bash
      2 
      3 # copy all contents of $1 on $2
      4 # giving unique name to directories
      5 # and put stuff in cache
      6 # with hardcoded list of exclusions
      7 
      8 set -x
      9 set -e
     10 
     11 FOLDER="$1"
     12 DEST="$2"
     13 shift
     14 shift
     15 
     16 cd "$FOLDER"
     17 # copy files to destination
     18 rsync -avzPy --progress --backup --exclude="cache/" --exclude="/papers/**" --exclude="wikipedia/**" ./ "$DEST"
     19 
     20 # move files to cache
     21 # TODO: this is inefficient and should be done with mv invocations
     22 # use, e.g., http://unix.stackexchange.com/a/155633/8446
     23 rsync -avzPy --remove-source-files --exclude="cache/" --exclude="/papers/**" --exclude="wikipedia/**" $EXCLUDE ./ "cache/"
     24 
     25 # now, remove remaining empty directories
     26 # find ./ -type d -empty -exec rmdir '{}' +
     27 # this doesn't really work, but anyway, the folder structure may still be useful
     28