views:

200

answers:

2

Greetings dear Experts!

Could you please advice me on how to cope with the problem:

@echo off
cls

setlocal enabledelayedexpansion

path=%CD%;%path% 

set NumberOfPages=553
rem set /A MaxFileIndex=%Counter% - 1
set MaxFileIndex=1

del Output.txt

for /l %%i in (0,1,%MaxFileIndex%) do call :GenerateFileList %%i
goto :eof


::::::::::::::::::::::::::
:GenerateFileList
::::::::::::::::::::::::::
setlocal enabledelayedexpansion

set CurrentFileName="File(%1).txt"
echo !CurrentFileName:"=! > Output.txt
goto :eof

::::::::::::::::::::::::::
:eof
::::::::::::::::::::::::::
endlocal

This code echoes on the screen instead of writing to "ExtractedLinks.txt". What is the problem here?

A: 

I assume you mean Output.txt not ExtractedLinks.txt:

set c=!CurrentFileName:"=!
echo %c% > Output.txt

Also, unless you are doing something else in the for loop, you probably want to append instead of overwriting:

echo %c% >> Output.txt

And if you really want the filename to be ExtractedLinks.txt just change it.

echo %c% >> ExtractedLinks.txt
Joseph Bui
+1  A: 

Dear Experts,

Thank you for your comments and answers. Actually I was trying to simulate for ... in ... do ( ... ) with this 'function'. Anyway, I've already got a solution.

Andrey