1.

Solve : Filename Glitch with "FOR" When Directing Output of Decompiler to TXT File?

Answer»

This should be a piece of cake for you folks, I'm trying to use "FOR" to decompile a bunch of files using a 3rd party decompiler. What I'm using works, but the filename of the output isn't coming out like I want it to, here's my command:

for %f in (*.agn) do agn2txt.exe %f > %f.txt

My files are all named like "001222031313031an.agn", "001222031313033an.agn", etc (autogen files for MS FLIGHT Simulator). I'd like the output .txt files to be named similarly, i.e. "001222031313031an.txt", "001222031313033an.txt", but instead I'm GETTING "001222031313031an.agn.txt", "001222031313033an.agn.txt"

I'm guessing it's blissfully simple, but how do I make it not include the ".agn" in the filename of the .txt file? I thought "%f" was a variable for the wildcard "*", but apparently it's everything within the parentheses? Do I need "delims"?

I'd appreciate any help someone can give me.

Thanks,
JimUse this:

CODE: [Select]> %~nf.txt
Help info on the modifiers is on the last page of for /?Cool, thanks foxidrive, much appreciated .

"%~nI - expands %I to a file name only"

I guess in this case it's %~nf just because I used %f rather than %I as my variable?

Thanks,
JimQuote from: JRobinson on June 22, 2013, 02:46:52 AM

I guess in this case it's %~nf just because I used %f rather than %I as my variable?

Yes, Jim. Glad to see it helped.Quote from: JRobinson on June 22, 2013, 02:46:52 AM
I guess in this case it's %~nf just because I used %f rather than %I as my variable?

In the examples in the FOR documentation, the character I (upper case i) is used as a placeholder for whatever letter you choose to use.

Quote from: Salmon Trout on June 23, 2013, 06:22:56 AM
In the examples in the FOR documentation, the character I (upper case i) is used as a placeholder for whatever letter you choose to use.

It's funny that. I learned in programming never to use an i I l 1 or o 0 O as a variable name because in in some fonts you can't tell which is which. Programmers of today don't seem to have learned that - and it being MICROSOFT makes it even more of an oversight.

Quote from: foxidrive on June 23, 2013, 07:02:55 AM
I learned in programming never to use an i I l 1 or o 0 O as a variable name because in in some fonts you can't tell which is which.

I have noticed that lots of example code uses lower case i or j as loop counters... I just confirmed you can use a pipe symbol in cmd provided you escape it:

Code: [Select]for %^| in (*.*) do @echo %^|
Code: [Select]@echo off
for %%^| in (*.bat) do echo %%^|

That's surprising.

I hate when people use things like %%# and especially %%? to confuse the newbies with wildcards.Quote from: foxidrive on June 23, 2013, 07:59:50 AM
That's surprising.

I hate when people use things like %%# and especially %%? to confuse the newbies with wildcards.
But Jeb writes some pretty wicked batch files.That's for sure.


Discussion

No Comment Found