开发者

batch script: including filehandle %%i in DO (subfunction

开发者 https://www.devze.com 2023-02-06 05:54 出处:网络
I\'m a bit stuck and need some advice. I start by doing a FOR loop with %%i as the file variable. for %%i in (\"C:\\*.*\") do (

I'm a bit stuck and need some advice.

I start by doing a FOR loop with %%i as the file variable.

for %%i in ("C:\*.*") do (
call :function1 "%%i"
goto function2
goto :eof
)

the problem is that the file-parameter isn't given to function one..

I have tested with putting an 'echo my 开发者_JAVA百科echo is %%' in function1 and i get:

my echo is %i

And exacltle the same for the use of %%i in function2

Does anyone has advice for me? How do i get the file handle to be taken to function in the DO form? By the way, this is windows batch.


@echo off
for %%i in ("C:\*.*") do (
  call :f "%%i"
)
pause
exit

:f
echo %1


I actually found the source of my nightmares and it was pretty simple. The solution mentioned by belisarius was good but it did made the rest of my code unusable.

So on the the solution:

for %%i in ("C:\*.*") do (
call :function1 "%%~i"
call :function2 "%%~i"

That's right! Damn brackets!! But that's a new lesson learnd ;) Thanx for your time Belisarius

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号