atwellpub
atwellpub

Reputation: 6010

If statement in command line loop for windows 7 bat file

I'm look to run an if statement in a for loop but am having issues. It should look something like this:

for %%a in (*.po) do (
    echo ' Translating %%a'

    if %%~na !='filename' msgfmt -cv -o %%~na.mo %%a
    if %%~na !='filename'  del %%a

)

But I'm seeing my filename.po converted and deleted still. What am I doing wrong. Do you see an error in my syntax?

Upvotes: 0

Views: 721

Answers (1)

foxidrive
foxidrive

Reputation: 41234

This could help:

for %%a in (*.po) do (
    echo ' Translating %%a'

    if /i not "%%~na"=="filename" (
        msgfmt -cv -o "%%~na.mo" "%%a"
        del "%%a"
    )
)

Upvotes: 1

Related Questions