ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Thu Oct 22, 2020 5:43 pm

All times are UTC




Post new topic  Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Thu Nov 24, 2016 6:46 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 11688
Just a quick tutorial for who wants to run any command-line tool in batch mode on all the files of a folder instead of running it manually for every single file.
So, for example, if you have 1000 fsb or xwb archives and you want to run fsbext and unxwb on them with a single command, that's the trick.

Create a file called file.bat in the target folder containing the following syntax:
Code:
for /r %%G in ("*") do COMMAND %%G

Where COMMAND must be replaced with the full command-line tool and argument you want to run, for example
Code:
for /r %%G in ("*.xwb") do unxwb -l %%G
As you can see I replaced also the * (for ANY file) with *.xwb for running the tool only on the files with XWB extension.
It's even possible to run multiple commands in sequence by appending &&:
Code:
for /r %%G in ("*.xwb") do md %%G_output && unxwb -d %%G_output %%G


You can also use this method from the cmd.exe console, you have only to replace %%G with %G.

Please note that the G in %%G can be anything, so if you prefer %%a you can use it too.

This topic is for anyone who wants to add other methods, tips, suggestions, examples and questions.
It's something that is often asked by users so it's very important to have a topic about it.

P.S.: a good link about this topic http://ss64.com/nt/for_r.html


Top
   
PostPosted: Thu Nov 24, 2016 11:27 pm 

Joined: Thu Nov 24, 2016 9:28 pm
Posts: 5
Thanks for the insight.

When I tried the last script, I get unsatisfactory results sadly.

Image

Each .xwb file that gets applied with unxwb.exe results in a 00000000.wav file, so it would lead to override requests. I tried to apply this batch to see how it goes, and it results in a request for an override to the new "00000000.wav" files, without change in file name (or replicate using the original file name with the new .wav extension).

Code:
for %%G in (*.xwb) do unxwb.exe "%%G"


Top
   
PostPosted: Fri Nov 25, 2016 8:51 am 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 11688
You forgot the && between the md command and unxwb.


Top
   
PostPosted: Fri Nov 25, 2016 9:14 am 

Joined: Thu Nov 24, 2016 9:28 pm
Posts: 5
Ah okay, tried it now and it gave 00000000.wav files in their respective generated folders as needed:

Code:
for %%G in ("*.xwb") do md %%G_output && unxwb.exe -d %%G_output %%G


Now to try and figure how to rename the files inside the folder to match with the folder name...

Thanks aluigi <3!!!

Edit: Got everything done for this rip, working on .pos modifications. This may seem off-topic, but do you know if unxwb will support loop pointer extraction in the future? The ADPCM format seems to play fine (in P4 Ultimax's case, offset 0xA4 ~ 0xA7 = Loop Start... offset 0xA8 ~ 0xAB = Loop Length starting from string "WBND"). I haven't looked at the other format types of .xwb files out there, but I'd guess that it would be different.


Top
   
PostPosted: Fri Nov 25, 2016 3:30 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 11688
No, there will be no support for these loops.
It extracts files from the XWB archives, that's it.


Top
   
PostPosted: Mon May 13, 2019 4:10 am 

Joined: Sat May 04, 2019 4:25 am
Posts: 11
aluigi wrote:
No, there will be no support for these loops.
It extracts files from the XWB archives, that's it.


I found some batch code on stackoverflow. Is there a way to run this code, and have it extract to the folder the .tex file is in (even if it ends up overwriting the file).

Currently this script asks if I want to create a new folder for every file with a Y/N question which is difficult when there are thousands of files to process, and it would create too many folders rather than leaving the folder/file structure as it is (I found out about the -Y option but it is still preferable to just overwrite the files)

Code:
for /R %%i in (*.tex) DO quickbms.exe -o script.bms "%%~i" "%%~dpni"


Top
   
PostPosted: Sun May 19, 2019 2:19 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 11688
I just reply on the fly so I may be wrong.
quickbms has 2 options, -d and -D that automatically create folders for the destination files.
Not sure if that's what you mean but you can try.


Top
   
PostPosted: Thu Jun 20, 2019 11:23 am 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 11688
Two examples about how to run offzip on multiple files in the current folder:
Code:
for %%G in ("*.ext") do md %%G_output && offzip -a %%G %%G_output

Code:
for %%G in ("*.zip") do md %%G_output && offzip -a -z -15 -Q %%G %%G_output

I didn't use /r because it forces the command to run on all the extracted files too... yeah very useless and annoying in most cases, except if you specify a different output folder:
Code:
for /r %%G in ("*") do md c:\output%%~pG%%~nG%%~xG && offzip -z -15 -Q -a %%G c:\output%%~pG%%~nG%%~xG


If you are interested in the additional syntax for %%G:
Code:
%~I         - expands %I removing any surrounding quotes (")
%~fI        - expands %I to a fully qualified path name
%~dI        - expands %I to a drive letter only
%~pI        - expands %I to a path only
%~nI        - expands %I to a file name only
%~xI        - expands %I to a file extension only
%~sI        - expanded path contains short names only
%~aI        - expands %I to file attributes of file
%~tI        - expands %I to date/time of file
%~zI        - expands %I to size of file


P.S.: my original example in the first post missed the "&&" for some unknown reasons, now fixed.


Top
   
PostPosted: Mon Jul 01, 2019 10:25 pm 

Joined: Sun Dec 21, 2014 7:43 pm
Posts: 35
aluigi wrote:
Two examples about how to run offzip on multiple files in the current folder:
Code:
for %%G in ("*.ext") do md %%G_output && offzip -a %%G %%G_output

Code:
for %%G in ("*.zip") do md %%G_output && offzip -a -z -15 -Q %%G %%G_output

I didn't use /r because it forces the command to run on all the extracted files too... yeah very useless and annoying in most cases, except if you specify a different output folder:
Code:
for /r %%G in ("*") do md c:\output%%~pG%%~nG%%~xG && offzip -z -15 -Q -a %%G c:\output%%~pG%%~nG%%~xG


If you are interested in the additional syntax for %%G:
Code:
%~I         - expands %I removing any surrounding quotes (")
%~fI        - expands %I to a fully qualified path name
%~dI        - expands %I to a drive letter only
%~pI        - expands %I to a path only
%~nI        - expands %I to a file name only
%~xI        - expands %I to a file extension only
%~sI        - expanded path contains short names only
%~aI        - expands %I to file attributes of file
%~tI        - expands %I to date/time of file
%~zI        - expands %I to size of file


P.S.: my original example in the first post missed the "&&" for some unknown reasons, now fixed.


you can use " /f " with some tricks...


for /f "delims=* tokens=*" %%a in ('dir /b /s *.zip *.rar') do ......

you can set a folder or concatenate another commands too

for /f "delims=* tokens=*" %%a in ('dir /b /s *.zip *.rar ^| findstr "english"') do echo %%~nxa


Top
   
PostPosted: Tue Sep 08, 2020 3:50 pm 

Joined: Tue Sep 08, 2020 3:31 pm
Posts: 12
As far as I understand is the method you are provide here exactly what I was looking for
a long time...

I can use this for every cmd-tool even the program don't support multiple file handling by itself right?

Edit:

Code:
for /r %%G in ("*.radp") do radp2wav.exe -l %%G


Any idea why it didn't work?


Top
   
PostPosted: Mon Sep 14, 2020 6:48 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 11688
@ExtractResponseUnit
If you use that command from console (cmd.exe) replace %% with %


Top
   
PostPosted: Tue Sep 15, 2020 12:06 am 

Joined: Tue Sep 08, 2020 3:31 pm
Posts: 12
Thanks for your responce aluigi

Actually I tried the command in a batch file. I also tried your suggestion above.

Same error log:
Code:
usage: radp2wav <inputfile> <outputfile>
input file does not exist
File "C:\radp2wav\test\-a" not found.
usage: radp2wav <inputfile> <outputfile>
input file does not exist
File "C:\radp2wav\test\-a" not found.


By the way: I'm a big fan of your QuickBMS tool, many thanks for inventing it.


Top
   
PostPosted: Wed Sep 16, 2020 6:41 pm 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 11688
As far as I can see that tool requires different arguments.
Maybe try:
Code:
for /r %%G in ("*.radp") do radp2wav.exe %%G %%G.wav


There is also a comment here regarding radp2wav on all the files from the command-line:
http://blog.gib.me/2009/06/21/prototype/comment-page-3/


Top
   
PostPosted: Sat Sep 19, 2020 12:47 am 

Joined: Tue Sep 08, 2020 3:31 pm
Posts: 12
Code:
usage: radp2wav <inputfile> <outputfile>


How to go round, I've tried it with different arguments it results always the same error...

I guess you got much more of experience than me so if it don't bother you I could upload the programm or
even the source code if you prefer


Attachments:
radp2wav.rar [19.61 KiB]
Downloaded 33 times
Top
   
PostPosted: Sat Oct 10, 2020 12:56 am 

Joined: Tue Sep 08, 2020 3:31 pm
Posts: 12
I hope at least one of the 12 guys who downloaded the source find a solution


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 15 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