Skip to content

Instantly share code, notes, and snippets.

@danielsaad
Last active October 18, 2018 02:47
Show Gist options
  • Save danielsaad/aaff2da13307d9b79632bc2bfe1a6dba to your computer and use it in GitHub Desktop.
Save danielsaad/aaff2da13307d9b79632bc2bfe1a6dba to your computer and use it in GitHub Desktop.
Script to copy Diablo files
import os.path
import subprocess
import datetime
# Global definitions
d2_folder = "/home/danielsaad/d2-113/Diablo II"
backup_folder = "/home/danielsaad/Dropbox/d2bkp"
# Create the backup folder
print("Creating Backup folder")
os.makedirs(backup_folder, exist_ok=True)
# Test for the existence of the savegame folder
savegame_folder = os.path.join(d2_folder, 'Save')
plugy_folder = os.path.join(d2_folder, 'PlugY')
if(not os.path.isdir(savegame_folder)):
print("Savegame folder", savegame_folder, "not present.")
exit(1)
if(not os.path.isdir(plugy_folder)):
print("Plugy folder", plugy_folder, "not present.")
exit(1)
# Create a new folder with date and time
now = datetime.datetime.now()
append = now.strftime("%Y-%m-%d %H:%M")
new_folder = os.path.join(backup_folder,'backup-') + append
os.makedirs(new_folder,exist_ok=False)
# Move the savegame into the new_folder
subprocess.run(['cp', '-r', savegame_folder, new_folder])
subprocess.run(['cp', '-r',plugy_folder, new_folder])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment