path fileName fileInformation
I have ran the 2nd for loop itself without the need for the 1st for loop and the subroutine and my 2nd loop displays all the text from tmp1.txt in the dos windows without issue. So, is the 2nd for loop passing each text line to the subroutine correctly? I can't get the subroutine to read each text line to seprate out the path, fileName, and file information.
So, basically, subroutine isn't recognizing the 2nd for loop's passing the text line into it. I can't see where the issue is at. Please assist.
Code: Select all
@ECHO OFF
:: 1st for loop
for /f %%N in ('find /v /c "" ^<"c:\temp1\tmp1.txt"') do set "cnt3=%%N"
:: 2nd for loop
SETLOCAL DisableDelayedExpansion
FOR /F "usebackq delims=" %%a in (`"findstr /n ^^ c:\temp1\tmp1.txt"`) do (
set "var=%%a"
SETLOCAL EnableDelayedExpansion
set "var=!var:*:=!"
CALL :01Cmd2Line !var!
:: echo(!var!
ENDLOCAL
)
:: subroutine
:01Cmd2Line
set var1=%1
for %%I in (%var1%) do set "Path=%%~dpI"& set "File=%%~nxI"& set "FileInfo=%%~atzI"
echo %Path% %File% %FileInfo% KB >> c:\temp1\FileOutput.txt
exit /b
pause
exit
text file tmp1.txt contains the following info:
- C:\Program Files\IDT\WDM\sttray.exe
C:\Program Files\Common Files\Java\Java Update\jusched.exe
C:\Program Files\AirTight\SpectraGuard SAFE\WSAUI.exe
C:\Program Files\McAfee\VirusScan Enterprise\SHSTAT.EXE
C:\Program Files\NVIDIA Corporation\nView\nwiz.exe
C:\Program Files\Renesas Electronics\USB 3.0 Host Controller Driver\Application\nusb3mon.exe
C:\Program Files\McAfee\Common Framework\udaterui.exe
C:\Program Files\McAfee\Policy Auditor Agent\PASysTray.exe
C:\Program Files\McAfee\Host Intrusion Prevention\FireTray.exe
C:\Program Files\Intel\Intel(R) Rapid Storage Technology\IAStorIcon.exe
C:\Program Files\STMicroelectronics\AccelerometerP11\FF_Protection.exe
C:\Program Files\Symantec\Symantec Endpoint Encryption Clients\Client Console\EAFRCliStart.exe
C:\Program Files\DellTPad\Apoint.exe
C:\Program Files\Common Files\Adobe\ARM\1.0\AdobeARM.exe
C:\Program Files\Adobe\Acrobat 10.0\Acrobat\Acrobat_sl.exe
C:\Program Files\Adobe\Acrobat 10.0\Acrobat\Acrotray.exe
C:\Program Files\ActivIdentity\ActivClient\acevents.exe
C:\Program Files\ActivIdentity\ActivClient\accrdsub.exe
subroutine output:
- C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\ Program KB
C:\Program Files\Gradkell Systems, Inc\DBsign Data Security Suite\Common\Lib\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\ActivIdentity\ActivClient\;C:\Program Files\Common Files\Roxio Shared\DLLShared\;C:\Windows\System32\Windows System Resource Manager\bin;;C:\Windows\idmu\common;C:\Windows\System32\WindowsPowerShell\v1.0\;c:\Program Files\UE;c:\Program Files\UE\bin KB