Last active
July 25, 2022 13:19
-
-
Save rsperl/7e7a69fc6e78577529ae5bc4abbc6178 to your computer and use it in GitHub Desktop.
backup a file with a timestamp #python #snippet
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from datetime import datetime | |
import shutil | |
origfile = "myfile.txt" | |
backupfile = origfile + "." + datetime.now().strftime("%Y-%m-%d_%H%M%S") | |
shutil.copy(origfile, backupfile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment