Sep-08-2023, 02:07 PM
(Aug-17-2023, 03:20 PM)deanhystad Wrote: Do you really mean "C:\Users\User\Desktop" or do you mean the desktop for the current user? If the latter, you can ask windows for the current user's %HOMEPATH%. This program lists all the files on your desktop.
import os from pathlib import Path desktop = Path(os.environ["USERPROFILE"]) / "Desktop" print(*desktop.iterdir(), sep="\n")To get paths for Desktop\tabs.json and Desktop\tabs_oldercopywithalternatelinks.json:
work_files = desktop / "the-great-suspender-restore-urls-0.4" tabs_path = work_files / "tabs.json" tabs_copy_path = work_files / "bs_oldercopywithalternatelinks.json"if the path is really hard coded (will always be C:\Users\User\Desktop\the-great-suspender-restore-urls-0.4), use a string. I suggest changing the "\" to "/" so Python doesn't interpret "\the" as "<tab>he".
from pathlib import Path work_files = Path("C:/Users/User/Desktop/the-great-suspender-restore-urls-0.4") tabs_path = work_files / "tabs.json" tabs_copy_path = work_files / "bs_oldercopywithalternatelinks.json"
I chose the third code excerpt, as it's exactly what I need! ^_^ Just one more question: Where exactly do I put the third code excerpt into the main code?