pointeman
asked on
DOS For In Dir Pass Fullpath?
Working with two DOS files. Currently I 'pass' the filename.ext to bat2, however I would like to send the entire fullpath.
Help :)
[bat1]
For %%a In ("C:\Program Files\Applications\Files\* .*") Do Call bat2.bat %%~na %%~xa
[bat2]
Echo %1%2
Help :)
[bat1]
For %%a In ("C:\Program Files\Applications\Files\*
[bat2]
Echo %1%2
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think the author wanted the filetype split off and passed as a separate argument from the rest of the file name (and path). There's a space between the arguments when passed to the bat2. But you may be right.
PS. I left my c:\temp testing path in the code when I posted earlier. Here it is with the right folder:
PS. I left my c:\temp testing path in the code when I posted earlier. Here it is with the right folder:
For %%I In ("C:\Program Files\Applications\Files\*.*") Do Call bat2.bat %%~dpnI %%~xI
ASKER
sjklein42
Q. "a" already has a meaning?
I used you code as is and I receive the following:
Echo C:\Program Files\Applications\Files\f ilenames.. ....
Echo C:\Program
Q. "a" already has a meaning?
I used you code as is and I receive the following:
Echo C:\Program Files\Applications\Files\f
Echo C:\Program
ASKER
billprew
Yes, it is just that simple (%%~a)... :)
Yes, it is just that simple (%%~a)... :)
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You both helped greatly :)
Welcome.
~bp
~bp
Note the ~dpn which give drive and path and name:
I recommend you use the letter "I" instead of "a" for the for loop variable. It will prevent some issues downstream as "a" already has a meaning.
Open in new window
%~I - expands %I removing any surrounding quotes (")
%~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 - expanded path contains short names only
%~aI - expands %I to file attributes of file
%~tI - expands %I to date/time of file
%~zI - expands %I to size of file