Created
October 12, 2018 09:25
-
-
Save gaikwad411/1cc9e602bd949e3e590a3299e8f98ab3 to your computer and use it in GitHub Desktop.
copy_file_in_same_dir_with_diff_name
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
import os | |
import datetime | |
original_file_path = __file__ | |
copied_file_path = 'copy_' + datetime.datetime.now().strftime('%d_%m_%Y_%H_%M_%S') + '_'+os.path.basename(original_file_path) | |
with open(original_file_path, 'rb') as original_file: | |
with open(os.path.join(os.path.dirname(original_file_path), copied_file_path), 'wb') as copied_file: | |
copied_file.write(original_file.read()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment