To use the program, specify an input file, an output file, and pairs of strings to search and replace.
java -jar modifyatn.jar [--lenient-le] inputFile outputFile searchString replacementString [searchString2 replacementString2 [...]]If any of the parameters contain spaces (e.g. filenames with spaces or search strings with spaces), put quotes around the entire parameter.
By default, the detection used for little-endian strings is strict. The byte counts must match expected values, and a signature "txtu" must be present. If these turn out to vary, the "--lenient-le" option can be used to force a lenient interpretation.
Example: java -jar modifyatn.jar input.atn output.atn "hello world" "goodbye world" world everyone
This will replace "hello world" with "goodbye world", and then make a second pass replacing "world" with "everyone".
Rick Ralston posted a tutorial for OS X (which should be similar under Windows) on his site "The Automatist" at http://www.theautomatist.com/the_automatist/2008/08/tutorial-editing-photoshop-actions-atn-files-with-java.html.
UTF-16BE (big-endian) strings | |
---|---|
DWORD | Big-endian length of string in characters, including terminal null. |
WORD[] | Big-endian characters, including terminal null. |
UTF-16LE (little-endian) strings | |
---|---|
DWORD | Big-endian, size of string in bytes + 12. |
BYTE[4] | String "txtu". |
DWORD | Little-endian, size of string in bytes + 12. |
DWORD | Little-endian, length of string in characters including terminal null. |
WORD[] | Little-endian characters, including terminal null. |
While writing this program, I tried a couple approaches, but settled on just reading the whole file as a byte[] for simplicity, and refined the program from there. The first version was actually a FilterInputStream that maintained read-ahead and read-behind buffers, with output lagging behind input (output was written as data expired from the read-behind buffer).
Copyright (c) 2008 Paul Miner <$firstname.$lastname@gmail.com>