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 :)

For %%a In ("C:\Program Files\Applications\Files\*.*") Do Call bat2.bat %%~na %%~xa

Echo %1%2
Who is Participating?
Bill PrewConnect With a Mentor Commented:
The way your FRO loop is coded the loop variable will by default be the full path, so it's a simple as:

For %%a In ("C:\Program Files\Applications\Files\*.*") Do Call bat2.bat "%%~a"


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.

For %%I In ("C:\temp\*.*") Do Call bat2.bat %%~dpnI %%~xI

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
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:

 For %%I In ("C:\Program Files\Applications\Files\*.*") Do Call bat2.bat %%~dpnI %%~xI 

Open in new window

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

pointemanAuthor Commented:

Q. "a" already has a meaning?

I used you code as is and I receive the following:

Echo C:\Program Files\Applications\Files\filenames......
Echo C:\Program
pointemanAuthor Commented:

Yes, it is just that simple (%%~a)... :)
sjklein42Connect With a Mentor Commented:
Sorry, forgot the double quotes when calling bat2.

 For %%I In ("C:\Program Files\Applications\Files\*.*") Do Call bat2.bat "%%~dpnI" "%%~xI"

Open in new window

%a works most of the time but I find that when I use the %~xxx notation to extract just particular parts of the filename, it sometimes gets confused if the letter I use for the variable is also one of the special characters listed in my note above.
pointemanAuthor Commented:
You both helped greatly :)
Bill PrewCommented:

All Courses

From novice to tech pro — start learning today.