Created
June 4, 2020 22:00
-
-
Save h4ndzdatm0ld/f070f326877a3f845b37f1ff4fafefe8 to your computer and use it in GitHub Desktop.
backup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def csvbackup(REGEX, FOLDER): | |
""" Find any file with the REGEX pattern in the PWD | |
and send it to assigned FOLDER. | |
""" | |
try: | |
current = os.getcwd() | |
files = glob.iglob(os.path.join(current, REGEX)) | |
DST_FLD = current + '/' + FOLDER | |
for bkup in files: | |
if os.path.isfile(bkup): | |
shutil.move(bkup, DST_FLD) | |
except Exception as e: | |
# print(e) | |
os.rename(bkup, (f"{bkup}-old.csv")) | |
csvbackup("*old.csv", FOLDER) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment