ZenHAX
http://zenhax.com/

Batch file trimming?
http://zenhax.com/viewtopic.php?f=11&t=3258
Page 1 of 1

Author:  Doctor Loboto [ Mon Oct 17, 2016 6:33 am ]
Post subject:  Batch file trimming?

Hey all, I was hoping someone could help me with a little issue I've been having. I have over 200 files, and I want to trim them all up to the first appearance of a specific string. I need a batch file for command prompt, or even quickbms, to do this preferably.
Basically I want to do this for all files.

Go from
"miscellaneousclutterCTPKfollowed"
to
"CTPKfollowed"

Essentially I want to delete everything in the file BEFORE the string "CTPK" appears.

Can anyone help?

Author:  aluigi [ Mon Oct 17, 2016 11:09 am ]
Post subject:  Re: Batch file trimming?

something like this, probably you want to "work" on the NAME variable:
Code:
findloc OFFSET binary "CTPK"
get SIZE asize
math SIZE - OFFSET
get NAME filename
log NAME OFFSET SIZE

Author:  Doctor Loboto [ Mon Oct 17, 2016 1:25 pm ]
Post subject:  Re: Batch file trimming?

All right, that works. Thanks much. On a minor addendum to this, how would one go about specifying that the SECOND occurrence of a string is the one that needs to be trimmed to? For example:

"miscellaneousdataTGXTmoredataGXTfollowing"
to
"GXTfollowing"?

Author:  aluigi [ Mon Oct 17, 2016 3:42 pm ]
Post subject:  Re: Batch file trimming?

Replace:
Code:
get SIZE asize
with
Code:
goto OFFSET
findloc SIZE binary "THE OTHER PATTERN YOU WANT TO SEARCH"
math SIZE - OFFSET
It's important that the second pattern is different than the first one or you will find it again, if it's the same it's enough to add a "getdstring DUMMY 4" before the above code to skip the first pattern found.

Author:  Doctor Loboto [ Mon Oct 17, 2016 3:55 pm ]
Post subject:  Re: Batch file trimming?

It doesn't seem to be working. Basically what I need to do is delete everything in the file before the EXACT string "GXT" is found, including the "TGXT" being deleted.

Author:  Doctor Loboto [ Thu May 11, 2017 6:24 pm ]
Post subject:  Re: Batch file trimming?

Ok, one quick question, how would I go about deleting everything up to and INCLUDING the first "3DS-LZ" in a file?

Author:  aluigi [ Thu May 11, 2017 8:00 pm ]
Post subject:  Re: Batch file trimming?

Code:
findloc OFFSET string "3DS-LZ"
math OFFSET + 6
get SIZE asize
math SIZE - OFFSET
log "new.dat" OFFSET SIZE

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/