Reputation: 178
Since the Microsoft quickaccess feature is very slow I prefer not to use it, and sometimes loading a folder takes too much time as well, I made a simple script to jump more easily among my "favorite" folders.
i.e. I open a cmd and type gt tools g
, the gt.bat script will go to the folder and then open gvim in that folder.
Since I'm a freshman in shell scripting the syntax is as easy as it gets:
if /I "%1" == "tools" goto TOOLS
if /I "%1" == "dow" goto DOW
:: ...a couple rows below...
:TOOLS
cd /d "G:\Shared drive\Stuff\Tools\"
goto EV2
:DOW
cd /d "C:\Users\myself\Downloads"
goto EV2
:: ... and so on for some 10 folders and again the second argument
I need to do cd /d <folder>
because some folders are on a shared drive and some on C:, and on cmd it's the only way to navigate between drives.
Problem: if instead of cmd.exe I use PowerShell, the syntax cd /d <folder>
is wrong. I should now use cd regardless of where I am, and the script fails otherwise.
I guess the easiest solution is to check whether the script was launched by cmd or powershell, but I can't find a command for that.
Any suggestion? Or maybe it's better to stick to one type of shell?
Upvotes: 0
Views: 70
Reputation: 4301
If you're trying to distinguish between CMD and Powershell only because of cd /d driveletter:
, why don't you try:
if /I "%1" == "tools" goto TOOLS
if /I "%1" == "dow" goto DOW
:: ...a couple rows below...
:TOOLS
G:
cd "\Shared drive\Stuff\Tools\"
goto EV2
:DOW
C:
cd "\Users\myself\Downloads"
goto EV2
:: ... and so on for some 10 folders and again the second argument
Upvotes: 1