Working with Files

User Rating:  / 0
    1. backup with rsync
      1. rsync -avz /home/mine/ /media/2TB_backup/Backup/
    2. you cannot batch change the name by move/copy multiple files with spaces in them mv cp can't split a file into pieces which is stupidly what your asking it to do. Very very syntax sensitive linux is
      1. mv *.* *.jpg
        1. with spaces in a filename your asking it to move “my taxes.jpg” to my.jpg taxes.jpg
        2. so use the command below to batch rename files removing spaces and special characters first
    3. jpg renaming to fit in with photobuckets ftp naming convention
      1. find -iname "*.jpg" | for files in *; do mv "$files" `echo "$files" | tr [:upper:] [:lower:] | tr [:punct:] '-' | tr [:blank:] '_' | sed -e 's/-jpg/.jpg/'`;done
      2. find -iname "*.jpg" | for files in *; do mv "$files" `echo "$files" | tr [:upper:] [:lower:] | tr [:punct:] '-' | tr [:blank:] '_' | sed -e 's/'-'/'_-'/g' | sed -e 's/-jpg/.jpg/'`;done
    4. other various bulk renaming tasks
      1. find -iname "*" | for files in *; do mv -i "$files" `echo "$files" | sed 's/jpg-1/jpg/'`;done
        1. this one replaces “jpg-1” with “jpg” modify to suit
    5. This one will add a B before the filename of every file in a directory that matches
      1. find -iname "*.mp4" | for files in *; do mv "$files" `echo B"$files"`;done
    6. tar -zxvf yourfile.tar.gz
    7. moving files whose names are in certain ranges
      1. for files in [a-c]*; do echo "$files" ;done 
      2. for files in [a-c]*; do mv -v "$files" /home/mine/ ;done
      3. for files in [d-f]*; do mv -v "$files" /home/mine/ ;done 
      4. for files in [h-m]*; do mv -v "$files" /home/mine ;done
      5. for files in [n-r]*; do mv -v "$files" /home/mine/ ;done
      6. for files in [s-v]*; do mv -v "$files" /home/mine/ ;done
      7. for files in [x-z]*; do mv -v "$files" /home/mine/ ;done