Skip to content

Instantly share code, notes, and snippets.

@lsloan
Created March 27, 2016 17:45
Show Gist options
  • Save lsloan/9f44885ece94d4f30ff4 to your computer and use it in GitHub Desktop.
Save lsloan/9f44885ece94d4f30ff4 to your computer and use it in GitHub Desktop.
import console
import editor
import os
import shutil
DOCUMENTS = os.path.expanduser("~/Documents")
old_name = editor.get_path()
new_name = os.path.join(DOCUMENTS, console.input_alert("Duplicate File", "Enter new name", os.path.relpath(old_name, DOCUMENTS)))
if os.path.exists(new_name):
console.hud_alert("Destination already exists", "error")
else:
shutil.copy(old_name, new_name)
##editor.open_file(os.path.relpath(new_name, DOCUMENTS)) # For old Pythonistas
editor.open_file(new_name)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment