0

I am writing a batch file which will identify the names of all .jak files in a directory (location specified) and convert them to .java files using AHEAD composer. The batch file code:

@echo off

set PATH=%PATH%;C:\AHEAD\ahead-v2013.03.20\build\bin;
set PATH=%PATH%;C:\Program Files\Java\jdk1.7.0\bin;
set PATH=%PATH%;C:\Program Files\apache-ant-1.9.3\bin;
set PATH=%PATH%;C:\AHEAD\ahead-v2013.03.20\miscellaneous\javacc\bin;
set PATH=%PATH%;C:\Cygwin\bin;

dir C:\AHEAD\JAK\*.jak /b >> list.txt

for /F "tokens=*" %%a in (list.txt) do call :Foo %%a
goto End

:Foo
set z=%1
echo %z%
jak2java %z%
goto :eof

:End

PAUSE;

cmd

With this i am getting the error System cannot find batch label specified -Foo But the same program works well for javac command and .java files

Rahul
  • 76,197
  • 13
  • 71
  • 125
Pritam
  • 39
  • 5

1 Answers1

0

Not possible; I tried a simplified version of your code (as below) and it worked fine.

Most probably it's a file format issue. Make sure that the file is in DOS format. Best is; copy the above posted code to a new editor (say, notepad) and save it with *.bat extension and then try running it.

Check out this threads as well

Why "The system cannot find the batch label specified" is thrown even if label exists?

http://help.wugnet.com/windows/system-find-batch-label-ftopict615555.html

@echo off

dir D:\Songs-mp3\English\*.mp3 /b >> list.txt

for /F "tokens=*" %%a in (list.txt) do call :Foo %%a
goto End

:Foo
set z=%1
echo %z%
goto :eof

:End

PAUSE;

cmd
Community
  • 1
  • 1
Rahul
  • 76,197
  • 13
  • 71
  • 125
  • It works for printing the file contents, it even works for "javac" command but when I run the .bat file executing jak2java command it throws the mentioned error. – Pritam May 02 '14 at 11:06
  • @user3594994, that's strange. In that case problem is with `jak2java` and not specific to `batch`. what if you run this command `jak2java X.jak` directly in command prompt. Does it run successfully? – Rahul May 02 '14 at 17:38
  • Yes, if I run jak2java x.jak in command prompt it works successfully. Also it works well even in .bat file when I explicitly mention the file name "x.jak". But I need to get the file names dynamically from a folder. – Pritam Jul 22 '14 at 14:09