Browse Prior Art Database

Command for changing the current command prompt directory by filename

IP.com Disclosure Number: IPCOM000029410D
Original Publication Date: 2004-Jun-28
Included in the Prior Art Database: 2004-Jun-28
Document File: 7 page(s) / 99K

Publishing Venue

IBM

Abstract

One of the weaknesses in the command prompt change directory (CD) command is that it does not easily allow a way of using the filename one is looking for to determine the directory to change to. The user must perform an awkward sequence of DIR and CD commands with considerable retyping, or copy-paste, to achieve the effect. This article proposes a simple command and a written solution to changing the current directory based on a filename.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 24% of the total text.

Page 1 of 7

Command for changing the current command prompt directory by filename

Although the graphical user interface, such as Windows* Explorer, is suitable for many computer related tasks the lowly command prompt (or DOS prompt as it used to be known) is still used heavily in many areas. For example in the role of program development the command prompt is used for many operations ranging from tools such as 'grep' to running make utilities. In JAVA** programming the directory structure can often become significantly more complicated with many levels in the hierarchy. This has highlighted a weakness in the current range of commands available at the command prompt. A key feature of a command prompt is that of the 'current directory'. The current directory is the place in the file hierarchy where, by default, any entered command will act upon. Consequently it is often important to ensure that one is in the correct current directory. The problem with the current command set is that the command to change the current directory is very heavily directory name based. The commands currently available are:-
cd .. This moves up one directory
cd <directory name> This moves to the named directory

    With simple directory structures these commands are adequate but it is not unreasonable in JAVA development to have over 10 levels of directory names. To move up and down this structure requires a lot of typing and is therefore laborious, error-prone and slow.

    The idea behind this article is to allow one to change to a directory containing a file one is looking for by using the file name rather than the directory name. Using the example of program development above one would issue a command such as :- cdf MyClass.java

    The command scans downwards in the current hierarchy until it finds a suitable match on file name. The user is then prompted to see whether this instance of the file is the one of interest. If the user responds 'yes' then the current directory is changed to the one where the file was found. If the user responds 'no' then the search through the directory tree continues.

    The full syntax of the command is :- cdf [-p] <filename>

    The -p flag allows the user to remove the prompt step and have the command change the directory to the first match it finds.

    The filename can contain wildcards according to the rules of the operating system it is running on. The filename may also contain a path and disk letter. For example, the following are possible :-
C:\tools> cdf MyClass.java Searches from the current directory for file MyClass.java
C:\tools> cdf \MyClass.java Searches from root of the current drive for file MyClass.java
C:\tools> cdf d:\MyClass.java Searches from root of the d: drive for file MyClass.java
C:\tools> cdf d:\programs\*.java Searches from \programs directory of the d: drive for all files of type .java

    A version of this command has been produced below for the Microsoft*** Windows Operating System and similar implementations can easily be achieved f...