Hopefully "ScriptingTipsAndTricks" helps you with your batch file or vbscript scripting :-)
[Bottom][Contents][Prev]: Absolute & Relative File or Directory Names[Next]: Environment Variables (used to configure or store information)
\->Introduction->Current Directory (or Drive)

Current Directory (or Drive)

The "current directory" is the folder for which files without a path refer to. For example I could type the following commands::

#1: TYPE "C:\TMP\SomeFile.txt"
#2: TYPE        "SomeFile.txt"

In command #1 I am telling the "TYPE" command exactly what file I want listed (typed). In command #2 I did not specify the path to the file so it will look at the current directory.

Quite often the name of the current directory will appear in the command "prompt" as shown below (before the "ECHO" command):

C:\TMP> ECHO The Current dir is "%CD%"
The Current dir is "C:\TMP"

The "CD" environment variable is used above to display the location of the current directory.

Note that there is a "current directory" for each drive letter and so there is also the concept of a current drive, the following shows changing the current drive as well as typing the contents of the file ("C:\TMP\SomeFile.txt"):

C:\TMP> D:
D:\ > CD \FolderOnD"
D:\FolderOnD > TYPE "C:SomeFile.txt"

Both "C:SomeFile.txt" and "SomeFile.txt" are relative filenames as they depend on what the current directory or drive is and "C:\TMP\SomeFile.txt" is called an absolute filename as the name of the file is fully qualified.


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: Absolute & Relative File or Directory Names[Next]: Environment Variables (used to configure or store information)


ScriptingTipsAndTricks© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Sunday September 07 2014 at 12:50pm
Visit ScriptingTipsAndTricks's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.