|
Answer» So I'm working on a batch file that will GENERATE a list of all files in the current directory with absolute path ready for input into another script. Here's what I've got so far.
list.bat Code: [Select]@ECHO OFF DIR /B /A:-D > temp.txt FOR /F "tokens=1" %%i IN (temp.txt) DO ( ECHO %~d1,%~p1,%%i >> list.txt ) del temp.txt
The problem I am having is it runs perfect so long as list.bat is in the same directory as the other files to be listed. So for instance lets say I move list.bat to C:\Windows\ so I can call it from anywhere on the computer. I go to C:\Maintenance\Patches and Updates\, and then run list.bat Instead of getting C:,\Maintenance\Patches and Updates\,[File] I get an output of C:,\Windows\,[File]. Any Ideas? Also on a more minor note, temp.txt is added to the LISTING for some REASON, anyone KNOW why?Update: Ok So anyone know why list.bat ./ causes it to work properly and how I can implement that into the script so I don't have to type it with the batch file every time? Also still TRYING to figure out how to prevent temp.txt from going into the text file.list.bat
Code: [Select]@ECHO OFF DIR /B /A:-D > temp.txt FOR /F "tokens=1" %%i IN (temp.txt) DO ( IF "%%i"=="temp.txt" ( echo. ) ELSE (echo %~d1,%~p1,%%i >> l.txt) ) del temp.txt It works.
|