tags:

views:

80

answers:

1
ECHO @ECHO OFF ^& (IF EXIST "%%~dp0%~n1.swf" (DEL "%%~dp0%~n1.swf")) ^& %mxmlcPath% %opts% -file-specs "%%~dp0%~nx1" ^& (IF EXIST "%%~dp0%~n1.swf" (CALL "%%~dp0%~n1.swf") ELSE (PAUSE)) > "%~dpn1.bat"
REM Immediately execute the generated bat
@ECHO on
CALL "%~dpn1.bat"

It's really a mess for me(like ECHO @ECHO OFF,what's that intended for?), can someone elaborate it?

+6  A: 

First line generates the batch file (note the '>' redirecting the output to the file at the end of first line). Third line ensures the output will be visible, fourth line executes the batch file generated in first line.

As for what the generated batch do: it seems it recreates some swf file: first the swf file is deleted:

"(IF EXIST "%%~dp0%~n1.swf" (DEL "%%~dp0%~n1.swf"))" 

then it is created using program defined in mxmlcPath environment variable:

%mxmlcPath% %opts% -file-specs "%%~dp0%~nx1"

if it's created successfully, it runs it in default swf player:

(IF EXIST "%%~dp0%~n1.swf" (CALL "%%~dp0%~n1.swf")

in other cases it waits for user input (so you will be able to read all error messages, etc.):

ELSE (PAUSE)

Explanation of the syntax of all the "%~dp0", etc. is available in documentation of few windows commands, for example:

call /?
chalup
What about `ECHO @ECHO OFF`,what's that for?
Gtker
@Runner: echo outputs the rest of the line. Usually it outputs it to the screen, but with the redirecting operator at the end (`>`), it is output to a file. `@echo off` is a command to not display the current commands that are executing in a batch file. So as chalup said, this creates a batch file, and the first line of that created batch file will read `@echo off`, and then the rest...
JRL
I know `@ECHO OFF`,but why `ECHO @ECHO OFF`?
Gtker
type ECHO @ECHO OFF in the console window and see what will happen. Then type ECHO @ECHO OFF > generatedScript.bat and see the contents of generatedScript.bat
chalup