Well, clearly I'm not doing something right with this command, or it's a bit hosed, or both.
GET_DIRECTORY_ARRAY save save ~~
ACTION_PHP_EACH save AS from => to BEGIN
ACTION_IF FILE_EXISTS ~%to%/baldur.sav~ BEGIN
PRINT ~Updating saved game %to% ...~
COPY ~%to%/baldur.sav~ ~%to%/baldur.sav~
EDIT_SAV_FILE (~%SAV_FILE%~ STRING_EQUAL_CASE ~ar0602.are~ = 1) BEGIN
PATCH_PRINT ~Editing %SAV_FILE% ...~
// WRITE_ASCII 0x94 ~none~ #8 //Area script (was ar0602)
END
BUT_ONLY
END
END
I'm using an auto-save from the beginning of SoA for the test (I've moved others out of the save folder so it doesn't go through every bloody one). With the WRITE commented out, the code will execute, *but* it says it goes through not just ar0602.are, but default.toh and default.tot as well (the only files in the .sav).
With the WRITE uncommented, it fails on default.toh because it's smaller than my WRITE offset, but I don't want to patch that anyway, obviously.
Does SAV_FILE only get set after the EDIT_SAV_FILE ... BEGIN? From the way you described it, it happens before applying the patch_list, or should anyhow. I don't know what other "test" you'd want to use, other than files matching a certain pattern.
Also, I think it should DECOMPRESS the .sav only if it actually writes a change to the file, and COMPRESS again if it does. Otherwise, I'd have to keep track manually of whether it actually made a change, and reCOMPRESS everything if so. Unlike BAMs, SAVs don't indicate whether or not they're compressed (I'm guessing the game assumes they're always compressed).