Free Power Tools Brochure
Get Mark Minasi's
17-page guide today!



      

advertisement

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

January 29, 2002 07:29 PM

JSI Tip 4757. CMD prompt folder navigation tool?

Rating: (0)
Windows IT Pro
InstantDoc ID #76063


If you often use the CMD prompt and have to constantly navigate to complex folder paths, CCD.cmd will make your life easier.

Dean Wells, MSEtechnology, has scripted the ccd.cmd, which has the following help (CCD /?) syntax:

ERROR - Nothing to do, help switch supplied ... syntax as follows -

        CCD [any number or sequence of directory path components] [/R]
        ... /R causes the drive index to be rebuilt

        e.g. -
             CCD istrator applic data
             ... C:\Documents and Settings\Administrator\Application Data
             CCD D: /r
             ... Causes the index for drive D to be rebuilt

        NOTE - Drive specifiers must be the first argument supplied
On first use, I built an index for each of my drives:
CCD C: /r
CCD D: /r
Now, after opening a CMD prompt, I can navigate to the TIP4700 folder by typing:
C:\>ccd tip4700

STATUS - Multiple hits found as follows, using primary match ...

C:\InetPub\WWWRoot\SUBJ\TIP4700
C:\InetPub\WWWRoot\SUBJ\TIP4700\_vti_cnf

Type POPD to return to previous working directory
C:\InetPub\WWWRoot\SUBJ\TIP4700>
To return to the previous folder, type popd.

To navigate to D:\WebCompiler\JSITTARH\SUBJ\TIP4700, I type ccd d: tip4700:

Type POPD to return to previous working directory
D:\WebCompiler\JSITTARH\SUBJ\TIP4700>
CCD.cmd contains:
:: Cute CD - Dean Wells, MSEtechnology - January 2002

@echo off

:: Check and redefine arguments
set SYNTAXERR=yes
set TMPSW=%*
if not defined TMPSW (
        echo.
        set ERROR=No arguments supplied, syntax as follows -
        call :ERROR
        goto :END
)
set SW=%TMPSW:"=%
if "%SW%"

"/?" ( echo. set ERROR=Nothing to do, help switch supplied ... syntax as follows - call :ERROR goto :END ) if not defined SW ( echo. set ERROR=No arguments supplied, syntax as follows - call :ERROR goto :END ) if not defined TMPSW ( echo. set ERROR=No arguments supplied, syntax as follows - call :ERROR goto :END ) set TMPDIR=%SW: /R=% set DIR=%TMPDIR: /r=% :: Prepare remaining environment, temporary files and the index if "%DIR:~1,1%"

":" ( set DRIVE=%DIR:~0,1% ) else ( set DRIVE=%CD:~0,1% ) :: Set the index file location set INDEX=%TEMP%\%DRIVE%colon.ccd.index :: Check for forced rebuild switch only if /i "%SW%"

"/R" ( set REBUILD=yes set REBUILDONLY=yes ) :: Check for forced rebuild switch amongst other arguments if not "%DIR%"

"%SW%" ( set REBUILD=yes ) :: Check for absence of existing drive index if not exist %INDEX% ( set REBUILD=yes ) :: Convert case of drive letter (display purposes only) for %%c in (A B C D E F G H I J K L M N O P Q R S T U V W X Y Z) do if /i %DRIVE%

%%c set DRIVE=%%c :: Check for drive validity if not exist %DRIVE%: ( echo. set ERROR=Drive specifier was invalid - %DRIVE% call :ERROR goto :END ) :: Check for root argument only if "%DIR%"

"\" ( set SPECIALCASE=yes ) :: Check for drive letter only if /i "%DIR:~0,3%"

"%DRIVE%:" ( if "%REBUILD%"

"yes" ( set REBUILDONLY=yes ) else ( echo. set ERROR=Drive only specified, root of drive %DRIVE% assumed set SYNTAXERR=no call :ERROR echo. set SPECIALCASE=yes ) ) :: Check for drive letter plus root only if /i "%DIR:~0,4%"

"%DRIVE%:\" ( set SPECIALCASE=yes ) :: Rebuild index if necessary or requested if "%REBUILD%"

"yes" ( del %INDEX% 2>nul echo. echo STATUS - Building new directory index for drive %DRIVE% - Wait ... dir %DRIVE%:\ /s /ad /b >%INDEX% echo. echo Completed! ) :: Terminate if index rebuild was only argument supplied if "%REBUILDONLY%"

"yes" goto :END :: Check for special case target directory if "%SPECIALCASE%"

"yes" ( set DIR=%DRIVE%: goto :SPECIALCASE ) :: Check validity of existing index if not exist %INDEX% ( echo. set ERROR=The directory index for drive %DRIVE% could not be located set SYNTAXERR=no call :ERROR goto :END ) :: Create temporary index files copy %INDEX% %INDEX%.src /y 1>nul 2>&1 if not exist %INDEX%.src ( echo. set ERROR=The temporary index for drive %DRIVE% could not be created set SYNTAXERR=no call :ERROR goto :END ) :: Begin search for directory path strings supplied for %%s in (%DIR%) do ( copy %INDEX%.src %INDEX%.tgt /y 1>nul 2>&1 type %INDEX%.tgt | find /i "%%s" >%INDEX%.src ) :: Check for existence of temporary index files if not exist %INDEX%.src ( echo. set ERROR=Unable to read necessary temporary files set SYNTAXERR=no call :ERROR goto :END ) :: Set the target directory set /p DIR=nul del %INDEX%.src 2>nul set DRIVE= set DIR= set REBUILD= set COUNT= set INDEX= set TMPDIR= set TMPSW= set ERROR= set SYNTAXERR= set REBUILDONLY= set SW= set SPECIALCASE=


ARTICLE TOOLS

Add a Comment

There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

VB Script to enable user account

Do any of you guys have a VB script that could be used to enable a AD user account? We are setting up a "firecall" ID which will stay disabled until i...222-96219

advertisement

GOOGLE LINKS
SPONSORED LINKS
FEATURED LINKS

Podcasts

To successfully implement virtual desktops, IT administrators must carefully match user requirements to specific desktop technologies. Listen to this podcast to learn what you need to keep in mind when formulating your approach to desktop virtualization.

Downloads

PacketTrap IT is a comprehensive and affordable network management and application monitoring solution that solves problems associated with bandwidth, network and application performance, and connectivity. Gain insight into your network - try PacketTrapIT free for 21 days!

Web Seminars

Aside from its employees, data is an organization’s most important resource. Join Windows technical specialist and 11-time MVP John Savill to learn the best practices for managing data using features in Windows Server.
View this web seminar on demand!

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.