Last active
December 17, 2015 10:39
-
-
Save eddotman/5596056 to your computer and use it in GitHub Desktop.
Copies a file repeatedly on a timed loop. Useful for saving 'snapshots' of self-updating files (e.g. configurations of Monte Carlo simulations).
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
from time import sleep | |
from shutil import copyfile | |
import os | |
def copy_loop(total_loops, interval, src_file, dst_file): | |
for x in range(total_loops): | |
f_name = dst_file + "_" + str(x) | |
copyfile(src_file, f_name) | |
sleep(interval) | |
return "Copying completed successfully." | |
output_name = "TEST" | |
print copy_loop(10, 3600, os.path.dirname(os.path.realpath(__file__)) + "\\" + output_name, os.path.dirname(os.path.realpath(__file__)) + "\\" + output_name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment