Jump to content

Recommended Posts

Posted

1: How do you make an echo go to the next line?

2: how do you end a function?

:function
codezorz
codey
code
END

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Posted

1. I am not sure about a multiline echo statement. I have only seen an echo for each line and that is how I do it.

2. Use a label and Goto :EOF to emulate a function. You can use Call to execute the function.

A cmd script that I use for Handbrake CLI application that uses the function concept.

@echo off

set HANDBRAKE="%ProgramFiles%\Handbrake\hbcli.exe"

if not exist %HANDBRAKE% (
        echo %HANDBRAKE% not found
        pause
        exit
)

for /d %%i in (*) do (
        call :convert "%CD%\%%i\VIDEO_TS" "%CD%\%%i.avi"
)

exit

:convert
if exist %1 (
        if not exist %2 (
                @echo on
                %HANDBRAKE% --input %1 --output %2 --encoder xvid --aencoder ac3 --two-pass --deblock --arate 48
                @echo off
        ) else (
                echo Skipping %2 as exist already
        )
)
goto :EOF

The cmd script calls ":convert" with parameters "%CD%\%%i\VIDEO_TS" and "%CD%\%%i.avi". The values of the variables %1 and %2 are replaced with the parameters as previous mentioned. Once Goto :EOF is reached, then the script returns to the line following the Call statement.

Note:

EOF = end of file (in which above is used as an end of the called label)

:)

Posted

Thank you! Very nice example. I only need question 1 now.

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Posted

'New command' echo?

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Posted (edited)

I have often found excellent answers to my batch file questions here:

http://www.robvanderwoude.com/batchfiles.html

Excellent resource.

Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Posted

In one line like this:

echo This is line one && echo This is line two

Perfect! Thank you!

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Posted

*bump*

Gah...how do I make the line blank?

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Posted

Minor tweak: echo.

No space between 'echo' and the dot, or it will just echo '.'

:)

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...