Navigation

Search

Categories

On this page

go somewhere new

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 120
This Year: 1
This Month: 0
This Week: 0
Comments: 40

Sign In
Pick a theme:

# Friday, October 27, 2006
Friday, October 27, 2006 12:32:26 PM (Mountain Daylight Time, UTC-06:00) ( )

Open your command shell in Windows.

Start -> Run, CMD, <enter>

Go to a different drive, say, the D: volume, to a folder called \foo\bar

this might look like cd D:\foo\bar

Wait, I thought I said, CD, change directory.... what gives, I didn't go anywhere. When I say go, I mean go.

Here's how I go..

GO.CMD


@ECHO OFF
:: Change to 1 to display messages
SET DEBUG=0

:: Make sure there is a parameter
IF [%1]==[] GOTO MissingDir

:: If parameter 1 is a directory, it will have a nul file in it
:: If there is no nul, it's a file, not a directory
IF NOT EXIST %1\nul GOTO NotDir

:: Change working drive
:CWD
IF %DEBUG%==1 (
  ECHO %~d1
)
%~d1

:: Change working path
:CWP
cd "%~pn1"
GOTO :EOF

:: Missing a parameter
:MissingDir
ECHO You did not specify a place to go to
GOTO :Usage

:: Invalid Parameter
:NotDir
ECHO You specified a file, or an invalid directory
GOTO :EOF

:Usage
go.cmd DRIVE:\FULL\PATH\TO\FOLDER
GOTO :EOF

:End

Now, you can go anywhere, really...


Edit (12/18/2006)

This is really helpful, but I found myself using far too many keystrokes to open a console at the location in my clipboard.

Start + R -> cmd -> {ENTER} -> GO{SPACE}, ALT + E + P, {ENTER}... thats 12 keys to press to do this

Added an additional file to my %USERHOME% to automate this.

%USERHOME%\cgo.bat

cmd /k "c:\utils\go.cmd %1 && cls"

Now we're more like

Start + R -> cgo {SPACE} CTRL + V {ENTER}... Thats 9 keys. Thats a 25% reduction, and well worth my time in the one line script & the time documenting.

This saves me 1-3 seconds time I use it (average of 32)... amazing.

 

 

Comments [0] | | #