Code: Select all
for %%e in (%path%) do echo %%e
Where I'm trying to cycle though each file in the path. The problem is this batch file will not work since my path has spaces giving an error like \Program Files or \Intel\iCLS was not recognized at this time.
My ultimate goal is to make this batch file run. It was an example from the book Windows 7 and Vista Guide to Scripting, Automation, and Command Line Tools.
Code: Select all
@rem Example file which.bat
@echo off
if "%1" == "" (
echo Usage: which command
echo Locates the file run when you type 'command'.
exit /b
)
for %%d in (. %path%) do (
if "%~x1" == "" (
rem the user didn't type an extension so use the PATHEXT list
for %%e in (%pathext%) do (
if exist %%d\%1%%e (
echo %%d\%1%%e
exit /b
)
)
) else (
rem the user typed a specific extension, so look only for that
if exist %%d\%1 (
echo %%d\%1
exit /b
)
)
)
echo No file for %1 was found
Any help would be greatly appreciated.