From fa36a061c1fba3340df9895ba63ae1fc270ac034 Mon Sep 17 00:00:00 2001 From: Mars Niermann Date: Mon, 19 Feb 2024 21:29:08 +0100 Subject: [PATCH] Use parent folder instead of cwd for launching files --- README.md | 2 +- shortcut.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 29def63..58cfb21 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ Run `build.bat`, will result in a `shortcut.exe` file ## Usage -Run `shortcut.exe` or `shortcut.py` in a folder with `.lnk` or `.url` files \ No newline at end of file +Run `shortcut.exe` or `shortcut.py` in a subfolder of a folder with `.lnk` or `.url` files \ No newline at end of file diff --git a/shortcut.py b/shortcut.py index abfb780..e96b119 100644 --- a/shortcut.py +++ b/shortcut.py @@ -1,7 +1,7 @@ import os import random -files = os.listdir() +files = os.listdir("..") shortcuts = [] for file in files: @@ -9,4 +9,4 @@ for file in files: shortcuts.append(file) file = random.choice(shortcuts) -os.startfile(file) +os.startfile(f"..\\{file}")