Untitled


SUBMITTED BY: krasavchek

DATE: June 13, 2016, 11:51 a.m.

FORMAT: Python 3.0 Traceback

SIZE: 1.9 kB

HITS: 674

  1. # Script Name : backup_automater_services.py
  2. # Author : Craig Richards
  3. # Created : 24th October 2012
  4. # Last Modified : 13th February 2016
  5. # Version : 1.0.1
  6. # Modifications : 1.0.1 - Tidy up the comments and syntax
  7. # Description : This will go through and backup all my automator services workflows
  8. import shutil # Load the library module
  9. import datetime # Load the library module
  10. import os # Load the library module
  11. today = datetime.date.today() # Get Today's date
  12. todaystr = today.isoformat() # Format it so we can use the format to create the directory
  13. confdir = os.getenv("my_config") # Set the variable by getting the value from the OS setting
  14. dropbox = os.getenv("dropbox") # Set the variable by getting the value from the OS setting
  15. conffile = ('services.conf') # Set the variable as the name of the configuration file
  16. conffilename = os.path.join(confdir, conffile) # Set the variable by combining the path and the file name
  17. sourcedir = os.path.expanduser('~/Library/Services/') # Source directory of where the scripts are located
  18. destdir = os.path.join(dropbox, "My_backups"+"/"+"Automater_services"+todaystr+"/") # Combine several settings to create
  19. # the destination backup directory
  20. for file_name in open(conffilename): # Walk through the configuration file
  21. fname = file_name.strip() # Strip out the blank lines from the configuration file
  22. if fname: # For the lines that are not blank
  23. sourcefile = os.path.join(sourcedir, file_name.strip()) # Get the name of the source files to backup
  24. destfile = os.path.join(destdir, file_name.strip()) # Get the name of the destination file names
  25. shutil.copytree(sourcefile, destfile) # Copy the directories

comments powered by Disqus