Skip to content

Instantly share code, notes, and snippets.

@gaikwad411
Created October 12, 2018 09:25
Show Gist options
  • Save gaikwad411/1cc9e602bd949e3e590a3299e8f98ab3 to your computer and use it in GitHub Desktop.
Save gaikwad411/1cc9e602bd949e3e590a3299e8f98ab3 to your computer and use it in GitHub Desktop.
copy_file_in_same_dir_with_diff_name
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