ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Tue Apr 25, 2017 6:30 am

All times are UTC




Post new topic  Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Batch file trimming?
PostPosted: Mon Oct 17, 2016 6:33 am 

Joined: Sun May 31, 2015 2:23 am
Posts: 217
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?


Top
   
 Post subject: Re: Batch file trimming?
PostPosted: Mon Oct 17, 2016 11:09 am 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 5837
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


Top
   
 Post subject: Re: Batch file trimming?
PostPosted: Mon Oct 17, 2016 1:25 pm 

Joined: Sun May 31, 2015 2:23 am
Posts: 217
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"?


Top
   
 Post subject: Re: Batch file trimming?
PostPosted: Mon Oct 17, 2016 3:42 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 5837
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.


Top
   
 Post subject: Re: Batch file trimming?
PostPosted: Mon Oct 17, 2016 3:55 pm 

Joined: Sun May 31, 2015 2:23 am
Posts: 217
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.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 5 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited