2015-05-18 56 views
0

我有一个脚本,我想为目录中的每个文件调用一个函数。使用forfiles,我已经能够一一列举,如:在forfiles中使用呼叫

forfiles /p "%myPath%" /c "cmd /c echo @path NAME @file" 

注:mypath中是有空格的路径,所以我不得不把它里面""

不过,我需要使用的功能LaunchRun我在批处理文件已经,所以我尝试:

forfiles /p "%myPath%" /c "call:LaunchRun @path @file" 

凡我函数需要两个参数。问题是,我得到:

ERROR: El sistema no puede encontrar el archivo especificado.

Translanted:

Error: System can't find the specified file

因为我发现没有使用/c选项启动一个新的控制台每个例子,我TRID太,因为我与echo做之一:

forfiles /p "%myPath%" /c "cmd /c call:LaunchRun @path @file" 

但后来我得到:

Intento no válido de llamar una etiqueta por lotes fuera de un archivo de script por lotes.

翻译:

Invalid attempt to call batch label outside of a file batch script.

这似乎因为我在一个新的控制台调用它。

我该怎么做才能在循环上调用我的功能?

预先感谢您

回答

1

只需使用一个for循环:

for /r "%myPath%" %%a in (*) do call:LaunchRun "%%~a" "%%~nxa"