Reputation: 351
In a for loop it requires quotes around the string to recall the entire length (Of the folder) but this causes problems later on in the script. Is there any way to remove the quotation marks simply (Such as :~1,-1 used in the echo)?
@ECHO OFF
set ICOINI=Desktop.ini
for /D /R "%cd%" %%d IN (*) do (call :Write_File "%%~nd")
Pause
goto End_File
:Write_File
set FOLDER=%1
if /I %FOLDER%==Icon goto :EOF
if /I %FOLDER%==Extras goto :EOF
echo %FOLDER:~1,-1%
goto :EOF
:End_File
Upvotes: 0
Views: 232
Reputation: 4750
I agree with Endoro. Perhaps are times when there are spaces in %1. To accomodate that you should make these changes:
set "FOLDER=%~1"
if /I "%FOLDER%"=="Icon" goto :EOF
if /I "%FOLDER%"=="Extras" goto :EOF
echo %FOLDER%
Upvotes: 2