1.

Solve : Getting Path in DOS Command For syntax?

Answer»

In the following code:

for /f "tokens=1-6,* delims=/ " %%i in ('dir /s /a-d /-c %DefPath% ^|find "/"') do call :CheckAndPurge %%i %%J %%k %%l %%m %%n %%o

IE there is a Batch Folder on C: C:\Batch and there are two folders with the Testbatch_A & Test Batch_B which CONTAIN the same file.

How do I get the complete PATH of the file for the %%o parameter? Right now I am getting the filename only ie test.txt, but since I am using the /s in the DIR command I NEED the Full path including Drive included in the filename. IE C:\batch\TestBatch_A\test.txt

Any ideas?

Thanks!

BAs you can see if you were to type your dir command (dir /s /a-d /-c) it does not list the directory with the file name. It will simply tell you each Directory of at the top of the file listings. The dir command has no option to not only display each file but each file with its path.

If you're wanting to do something like that the only command that comes to my mind that will list the file with the full directory of the file is the attrib command.

Hope this helps.Thanks for the HELP,

There are some modifiers that can be used according to Microsoft. I haven't had any luck with getting the syntax correct. Here is the link see modifier section.

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/for.mspx


Variable with modifier Description
%~I
Expands %I which removes any surrounding quotation marks ("").

%~fI
Expands %I to a fully qualified path name.

%~dI
Expands %I to a drive letter only.

%~pI
Expands %I to a path only.

%~nI
Expands %I to a file name only.

%~xI
Expands %I to a file extension only.

%~sI
Expands path to contain short names only.

%~aI
Expands %I to the file attributes of file.

%~tI
Expands %I to the date and time of file.

%~zI
Expands %I to the size of file.

%~$PATH:I
Searches the directories listed in the PATH environment variable and expands %I to the fully qualified name of the first one found. If the environment variable name is not defined or the file is not found by the search, this modifier expands to the empty string.

Any help would be appreciated.

Byoung



Discussion

No Comment Found