Skip to content

Instantly share code, notes, and snippets.

@Colk-tech
Created July 27, 2020 08:17
Show Gist options
  • Save Colk-tech/b96040ff597dcb9ccb65f12b9090c434 to your computer and use it in GitHub Desktop.
Save Colk-tech/b96040ff597dcb9ccb65f12b9090c434 to your computer and use it in GitHub Desktop.
import os
import datetime
import shutil
DESKTOP_PATH = os.getenv("USERPROFILE") + r"\Desktop"
BACKUP_PATH = os.getenv("ESCAPE-FOLDER")
folder_name = BACKUP_PATH + r"/" + datetime.datetime.now().strftime("%Y%m%d%H%M%S")
def all_not_shortcuts():
files = os.listdir(DESKTOP_PATH)
return [file for file in files if not (file.lower().endswith(".lnk"))]
def do_escape(files):
os.makedirs(folder_name)
for file in files:
full_path = DESKTOP_PATH + r"/" + file
shutil.move(full_path, folder_name)
def main():
targets = all_not_shortcuts()
do_escape(targets)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment