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