Skip to content

Kaijuu, the Windows BAT File Butler

Technical discussion which is not directly related to VGM files. Talk about Hardware and Software.

Moderator: Staff

  • User avatar
  • (Jazz) Jackalope Offline
  • Posts: 131
  • Joined: 2022-04-23, 22:53:04
  • Location: On the YM2612 chip

Kaijuu, the Windows BAT File Butler

Post by (Jazz) Jackalope »

kaijuu is a Windows context menu shell extension. The context menu is the list you see when you right-click on a file or folder. kaijuu allows you to add your own custom actions to this menu.

Think of opening an unknown file type: Windows will ask you to associate a program with the file type. From there forward, double-clicking the file will open the file with that program.

kaijuu is a far more powerful version of this same concept. With kaijuu, you can assign as many rules as you want. You can apply the same rule to multiple file patterns. You can have more complex pattern matching for names. You can apply rules to folders. You can specify rules about how to handle single-file versus multi-file selection. You can send custom command-line parameters to the program. You can have rules on a per-user basis. And you can do all of this from an easy-to-use GUI.
What does this have to do with VGMs? Nothing on its own. But you can use it to replace a great deal of .BAT file and command line usage. No matter how comfortable you are with using those things, Kaijuu should give you considerable quality-of-life improvements in the form of speed alone.

As useful as Kaijuu is, it does have a few downsides:
  • It's Windows-only, of course.
  • For it to work, you have to run the program as an administrator at least once so you can install its DLL onto your system. This should be safe, but your system configuration could prevent you from doing so. If you can't install the extension, you're either SoL or will have to get an administrator to install it for you.
  • Your commands are stored in the Registry, a dealbreaker for some; however, kaijuu-tachi at least lets you export them to a file for transfer or safekeeping. (Registry usage is so each user can have separate command settings.)
  • Although version v06/Kaijuu-Tachi has many good bugfixes, it doesn't keep the +Icons feature, needs to be built from source (but mentions a program that can do this for you?), and doesn't have a quick and easy way to build a Win32 version.
The following bugs appear in Version 05 (+Icons version, at least) and have been fixed in Tachi/06:
  • Having too many commands created seems to make the program lose track of the order of commands, scrambling them every time.
  • Having the Rule Editor window open used a lot of CPU cycles for no reason. (Could it have been due to the implementation of icons?)
  • I'm not aware of any further or dangerous bugs (and doubt dangerous ones exist, based on the programmer), but if you need to use v05 it's possible you'll discover others.
If none of the above is a problem to you, then let's get started!


As copies of the binaries and source of the ancient v05 are gone or hard to find, I've mirrored them in the attachment:
  • kaijuu_v05.7z, 32-bit and 64-bit binaries
  • kaijuu_v05.tar.xz, v05 source
  • kaijuu_v0.5+icons_bin.zip, +Icons edition (32-bit and 64-bit binaries; Manual is missing!)
  • kaijuu_v0.5+icons_source.zip, +Icons edition source
Then there is version v06, in the form of Kaijuu-Tachi. The new readme/manual mentions a particular build of mingw to compile it with - but without knowing this I built it with a different one. The linked build has an installer, though; once it's installed, you should only need to run the cc.bat file (and maybe to copy (not move) some of the other source folders into kaijuu/obj, if it says things aren't found).

(If you are already using Kaijuu 05 and wish to upgrade, you don't need to Reset the Rules like the manual recommends. All my Rules carried over to Tachi-06 without any problems.)

The manual handily explains how to use Kaijuu (please do read it!), but I have further examples below which double as useful commands you can start using right away. It also doubles as a cheat sheet.

"Find Start Point"

We start with *.vg? for the Pattern, meaning to match all VGZs and VGMs. (The ? character actually matches any single character; * matches any amount of characters.)

Then, for the command:

Code: Select all

vgm2txt {file} 0 0:03 "{basename} start.txt"
As a power user, I have vgm2txt accessible from my path. As (presumably) a non-power user, you (still) have no idea what that means. The beauty of Kaijuu is, you can press "Select..." next to Command and navigate to the EXE of the tool you need to use; Kaijuu will fill out the full path for you. Then, at the end, you can add any arguments you need to finish out the Command you want.

Since vgm2txt can only work with one file, we use {file}, which has been supplied for us. The number arguments make a TXT of only the first three seconds of the file, which should be more than enough for most cases accounting for the silence buffer. Finally, to make an output filename that ends with "start" I used {basename}, to use the filename (without extension) of the VGM as a basis.

(I surrounded my custom filename with quotes because there's a space in it. Without them, the OS can't tell where each argument ends and the next starts.)

You can make any amount or type of rules you want, even if they're very similar. For my own convenience, I also made a vgm2txt rule that's the same as that one, except for the name and for omitting the start and end arguments (which makes vgm2txt prompt me for those arguments). I frequently put in custom ranges, so this makes for a really quick way to use vgm2txt. (On the other hand, you can't use the "output filename" option this way...)

"gems2rom"

Here's another useful example, which seems more complex but is very simple. We use a Pattern of * - ?? *.bin to match the output of GemsScan and, more importantly, ignore BIN files that don't match the filenames GemsScan produces. Then we create a Command that looks like this.

Code: Select all

"C:\my\path\to\gems2rom.exe" -o "{basename} g2r.bin" {files}
(Again, use Select to find the EXE, or fill in the correct path by hand.)

-o is needed to specify the output file of gems2rom. To name it dynamically, I use {basename} again; it will take the name from the first file in the list of {files} Kaijuu receives. (Yes, this'll include the word "Driver" et all.) Then, to keep the output and source filenames from being identical, I added "g2r" before the extension. (I could also have used the "smd" extension instead.)

With this Rule in place, you can now select all five GemsScan output files - Driver, Instruments, Envelopes, Sequences, and Samples - and Kaijuu will use them with gems2rom for you. But, you must note: Since you must give gems2rom the Driver file first, you'll have to menu-click on the Driver file to run the Rule on it.

Now, what did I tell you about quality-of-life, eh?

I have a few others but I'm exhausted..
Attachments
kaijuu05builds-source.7z
(1.06 MiB) Downloaded 38 times
I'm trying to add information found on the forums easier to find on the wiki. If I forget to credit you, please let me know (or edit the article if you don't want to wait).

WIPs: 2023-10-30
  • User avatar
  • (Jazz) Jackalope Offline
  • Posts: 131
  • Joined: 2022-04-23, 22:53:04
  • Location: On the YM2612 chip

Post by (Jazz) Jackalope »

Example 3 (Tricky!): Using Folders with vgm_tt

If you want to use vgm_tt with both VGMs and folders full of them, we'll need a whopping four rules total: two each for files and folders. Why? You don't want to accidentally destroy your good tags, so it's best to have "test" rules you can use first.

(Always remember that VGM backups are fast and easy with 7zip!)

We'll begin with the Folders form; Files are nearly identical, though they lack the -mname option and (of course)match on files. (Oh, and using *.vg? for the Pattern.)

This time, you must check Match Folders and uncheck Match Files. You also must use * for the Pattern, so any folders can be matched. Then once you've gotten the vgm_tt EXE into the command, this is all you have to do:

Code: Select all

cmd.exe /k vgm_tt -mname {files}
Ah, wait, something new showed up there. cmd.exe /k makes the command line window that appears stick around (into which, if you're interested, you can enter help cmd to learn why that's so). It's also key to running certain more complex commands, as we'll see later.

Note again, it's the folder/file you menu-click on that's considered the first in line: selection order has nothing to do with it. When using this Rule in -tag form, you must be extra careful to click the right folder.

I used the cmd.exe /k form because you'll need to be able to see the output, to make sure the correct folders/files are on the correct sides. But if you find the windows are in your way, there's another solution.

Code: Select all

cmd.exe /c vgm_tt -mname {files} > vgm_tt_results.txt
/c, unlike /k, makes sure ye commande line window goes away. Then, after the files list, a > funnels vgm_tt's output into a file of the name shown - which lands in the same folder as those you used this command on.

At this point, you will have noticed the flaw of this approach, which is: the folders have to be in the same parent folder together. This is also true if you use them on two VGMs. It should still be convenient to have in your bag of tricks.

Whichever name you give the test rules, make sure to distinguish them from the rules you make that have -tag in them.


Example 4: More Useful Commands For Which I Don't Feel Like Writing In-Depth Sections Since You Probably Get It Already

If you roll your own useful Rules/Commands, feel free to post them here!


"Change System Tag to SMD"

To change many (Mega Drive/Genesis) VGMs to use that System entry in both English and OG Language:

Code: Select all

cmd.exe /k FOR %A IN ({files}) DO vgm_tag -System:SMD %A
By changing the tags sent to vgm_tag, you can make similar commands to set the Creator field to your name/handle, or remove individual fields such as the date.

Code: Select all

cmd.exe /k FOR %A IN ({files}) DO vgm_tag -Year:"" %A

"Start in PAL lock mode"

Code: Select all

cmd /c "{file}" -r E
Using blastem.exe for the Pattern, you of course match any BlastEm executable. Using the cmd trick was the only way to use BlastEm's command line options with Kaijuu; sadly, it's not possible to make the Debugger output go to that window.

You can also make a similar Rule for running BlastEm in J or U mode.


"Convert to .wav"

Code: Select all

VGMPlay.exe -c General.MaxLoops=2 -w {files}
Without the -c and -w options after the EXE name, it becomes a "Play in VGMPlay" command.
I'm trying to add information found on the forums easier to find on the wiki. If I forget to credit you, please let me know (or edit the article if you don't want to wait).

WIPs: 2023-10-30
Post Reply