- Aug
- 2,256
- 108
Code:
::--------------------------------------------------------------------
:: BM.BTM
::
:: This batch file displays all environment variables
:: that begin with bm, which represent directory bookmarks.
::
:: To bookmark the current directory, usage is;
::
:: BM 1 or BM 2 or BM 3 .... or BM 9
::
:: If a bookmark does not exist for the number, then you will be asked
:: if you want to bookmark the current directory.
::
:: If a bookmark exists for the number, then the directory will be
:: changed to the bookmarked directory.
::
:: If you want to see the existing bookmarks, usage is;
::
:: BM
::
:: Joe Caverly - 2013/01/01
::--------------------------------------------------------------------
@setlocal
@echo off
::
:: If no parameters were passed to this batch file,
:: just display the existing bookmarks.
::
iff %# eq 0 then
::
:: Display all environment variables that begin with bm,
:: followed by one character
::
set bm?
else
::
:: Parameters have been passed to this batch file.
::
::
:: If the directory that the bookmark points to exists,
::
iff exist %[bm%1] then
::
:: Change to that directory once the batch file is done.
::
defer cd %[bm%1]
else
::
:: Ask the user if they want to bookmark this directory.
::
set yorn=n
inkey /C /P /K"yn" Do you want to set bm%1 = %_cwd %%yorn
iff %@lower[%yorn] eq y defer set bm%1=%_cwd
endiff
endiff
endlocal