Help on batch or script

Discussion in 'OS X Mavericks (10.9)' started by dcaccount, Oct 6, 2014.

  1. dcaccount macrumors regular

    Joined:
    Nov 17, 2013
    #1
    Hello,

    I back up my directories by zipping them and copying them to a usb stick after renaming them with the pattern: year(2 digits)month(2 digits)day(2 digits).zip.

    Can please anyone write a script to automate this task assuming that the directories name is "archive", "house and family", "job"?

    I would really appreciate, thanks, Daniele
     
  2. SlCKB0Y, Oct 10, 2014
    Last edited: Oct 11, 2014

    SlCKB0Y macrumors 68040

    SlCKB0Y

    Joined:
    Feb 25, 2012
    Location:
    Sydney, Australia
    #2
    Code:
    #!/bin/sh
    
    filename=$(date "+%Y-%m-%d.zip")
    zip $filename /path/to/archive/ /path/to/house\ and\ family/ /path/to/job/
    cp $filename /Volumes/USB/
    
    Once the file is saved you will need to "chmod +x scriptname.sh"
     
  3. dcaccount thread starter macrumors regular

    Joined:
    Nov 17, 2013
    #3
    Thank you so much.

    Very, very kind of you.

    Daniele
     

Share This Page