How to navigate backward one directory in the path string?
How to navigate backward one directory in the path string?
TL;DR at bottom
I want to make a “entertainment hub” on my Windows 11 PC. Consisting of Emulators and such. Everything is divided into subfolders, and I’m making shortcut icons to every single game and demos for easy and clean looking access.
But i want to future proof this so that it will work IF i choose to change the drive letter on the disk it’s currently on, or rename mother folders, or if i give the project to someone, it needs to work without hickups.
Folder structure right now is like this:
F:\Folder1\Folder2\Subfolders (as many as needed, one for each emulator)
F:\Folder1\Folder2\Icons
F:\Folder1\Folder2\Shortcuts
This shortcut folder is where every quick launch icon are located, they point towards the real place of what is to be executed. So one icon is specified to point towards F:\folder1\Folder2\Dreamcast\Games\SoulCalibur
And each shortcut icon has it’s own customized icon that is located in F:\Folder1\Folder2\Icons
The problem with future proofing is that this will only work properly if this is always installed on F: drive and the Folder1 and Folder2 name always stays the same. I am trying to find ways to circumvent this.
One thing i tried was to change the path in the shortcut icon that is located in the F:\folder1\Folder2\shortcuts folder from “F:\Folder1\Folder2\Dreamcast\Games” to “..\Dreamcast\Games”. This method is not allowed it seems. I was hoping it would just go one step back from where it’s executed, and rest would work flawlessly, this would solve my problems.
*But, it would NOT solve the customized Icons, they will disappear on reboot if the icons are not in the exact path i fetched them from.
So since that didn’t work, i thought maybe i could make a direct link to where this is located by simply make a “drive” that points there. For example HUB: which goes directly to F:\Folder1\Folder2\
But in Windows you aren’t allowed to to do this, you can only use Drive letters A-Z.
So i thought, well maybe i can just make a .BAT file with the command “subst Z: F:Folder1\” and let this .BAT file launch with Windows, at least i could make that part easier, but then again just having the entire project to always be on F: would be just as easy.
Then again i tried this and even though i do use Z: the icons still have the path “F:\Folder1\Folder2\”
So. Either i can go one step back in the Icon path, or i have will have to always have this located on F:\ or whatever drive i choose, better pick one far down on the list i guess just in case. Or i will have to make some sort of install script for this project that if i ever choose to move this around, the install script will properly change the path in every shortcut icon and move all the files to where they belong, but i have no programming skills and this sounded very workload heavy.
Anyone has any idea on what i should do?
TL;DR:
Instead of a shortcut icon using full path e.g. "F:Folder1\Folder2\Folder3\" to the file's location.
And since the shortcut is stored in: F:\Folder1\Folder2\Shortcuts
is there some way that the path in the shortcut can go one step beck similar to CD.. command?
So something like this: "..\Folder3\" instead of using full path like "F:\Folder1\Folder2\Folder3\"?
For this Project I'm planning to use a basic program named Link Fixer that allows me to modify all paths within every shortcut in a folder at once. I'm not certain about the icons I added, but it seems like a simple and fast solution right now. And to keep things straightforward, I'll just place it on the C drive.
Alternatively, you set a path string for the drive, folder, or subfolder that shortcuts will use. When modifications are needed, update the string definition without altering its name. For guidance, refer to the resources provided:
https://poshcode.gitbook.io/powershell-f...-variables
https://petri.com/powershell-set-environment-variable/
All folders point to their "parent" directory as "
..". Therefore, using "
CD .."
will consistently navigate one level back in the folder hierarchy.
Because I’m still unclear about your question or the intended shortcuts for working or interacting, that’s the only part I can address.
I just want to understand how to move one level back in the path string within an icon. The icon indicates the shortcut file's location using full paths. I need to navigate up one folder and then into the correct subfolder. If I can craft a path like this, I won't have to deal with renaming parent folders or transferring everything to a new drive with a different letter.
I searched extensively but couldn't locate a solution. The concepts I discovered don't seem to apply.
Then I experimented with generating names as drive letters, such as "HappyPlace". This method simply places files directly into the correct folder. However, it's limited since you can only use valid drive letters.
Next, I considered writing a .bat file that runs with Windows startup, assigning a drive letter like "subst X: F:\elsewhere\Happyplace" in CMD.
Then I thought about creating a .BAT file to run automatically at startup. But if I later need to move the folder or change the drive letter, this approach wouldn't work because the icon would still display the incorrect path.
I aim to confirm my comprehension of the task at hand.
The main goal is to obtain executable files currently stored in specific paths, such as:
"F:\Elsewhere\HappyPlace\psx\other subfolders or files
F:\Elsewhere\HappyPlace\dreamcast\other subfolders or files
F:\Elsewhere\HappyPlace\commodor64\other subfolders or files"
and to relocate their contents up to the psx, dreamcast, commodore64 subfolder levels.
The original intention is to transfer all relevant files into the designated shortcut folders without manually adjusting each file path.
Please note that I must ensure I have a complete understanding of the differences between the current situation and the desired outcome.
For clarity, here are two examples:
1) Current full hierarchy from drive downward:
- F:\Elsewhere\HappyPlace\psx
- F:\Elsewhere\HappyPlace\dreamcast
- F:\Elsewhere\HappyPlace\commodor64
2) Planned full hierarchy from drive downward:
- F:\Elsewhere\HappyPlace\Shortcuts
- [Path to psx folder]
- [Path to dreamcast folder]
- [Path to commodore64 folder]
Moving files here involves risks, as changing directories and shortcut icons separately can lead to inconsistencies. The process will likely need both actions together.
Some examples of file paths:
- Copy a file from a subfolder, move to the next level up, then replace or delete the original.
- Adjust shortcut icons so they point to updated locations after file relocation.
This is essential to grasp before proceeding.
Hello, thank you for your response. I revised my original post before you replied, but it seems the previous folder names weren't clear to you. I think it’s now easier to understand.
I will list the current folders:
F:\Folder1\Folder2\Dreamcast
F:\Folder1\Folder2\Amiga
F:\Folder1\Folder2\C64
F:\Folder1\Folder2\PSX
F:\Folder1\Folder2\Dragon32
F:\Folder1\Folder2\Shortcuts
F:\Folder1\Folder2\Icons
Inside these directories are the installed emulators, which will need to be set up anew if I decide to transfer this data to another computer. For instance, when double-clicking a .UAE file (Ultimate Amiga Emulator), Windows must recognize the location of UAE.
Each emulator—whether it's demos, games, or software—has its own folder within the emulator directory. Everything is organized properly and in the right place. However, to have a straightforward setup where I can run everything without opening each emulator individually, I prefer creating shortcuts. These shortcut icons will point to paths like "F:\Folder1\Folder2\*Emulator*", which could become an issue if the drive letter changes.
In such cases, I would have to manually adjust every shortcut and update the path, especially with hundreds of entries. Additionally, I found another challenge: even after fixing the shortcut paths, the customized icons might not function correctly after a system restart.
Currently, the only solution that works is sticking to the same drive letter, which avoids any confusion. As long as I don’t rename the folders, everything remains stable.
Establishing some string variables regarding the pathnames was the initial step. Using PowerShell instead of DOS. The output from "Get-Variable" when run at the prompt without quotes and with admin rights would be shown. Checking "$Env
😛" displays the current environment variable. Running "dir env:" reveals the available environment variables. Examining "Get-ChildItem" in the specified directory lists the files recursively. The reference provided links to a guide on using PowerShell to identify drives, folders, and subfolders. A sample path such as F:\Folder1\Folder2\Icons is created as a string variable. Adjusting the path when changing drives from "F:" to "N:" ensures correctness. Creating a test file and moving it tests the shortcut functionality. If the file isn't found, note any errors encountered. Always work with copies during testing.
When i wrote strings it seems i opened pandora's box or something. yeah i didn't really know what to call that path thingy. i need to look into this, i have actually never done anything about the stuff you just wrote. i need to test things. i feel i'm getting very close to just give this project a Drive letter and never ever change it lol. 😂