Windows batch scripts are always so hard to read. FWIW, I prefer to use Cygwin. You can just install using the defaults, then put Cygwin's bin
folder on your Windows PATH. That lets you use Linux commands like ls
at the Windows command prompt, and you can run Bash scripts. Those are still pretty difficult but much better than Windows batch scripts. For example, here is one of our export Bash scripts:
https://github.com/EsotericSoftware/spine-runtimes/blob/4.1/examples/export/export.sh
To run it without Cygwin you'd use sh export.sh
.
Anyway, it looks like you are doing -i x -o y -r z
which is importing JSON data files into Spine project files. The Skeleton loaded from the JSON data has an imagesPath, which in JSON is images
on the skeleton
. During import that will be used for the images path in the Spine project. If no folder at that path exists, Spine will use the parent folder of the JSON file + that path, if that exists. If no images path is set in the JSON data, then the parent folder of the JSON file is used for the images path.
After the above, the images path is made relative using the same rules as if you pasted a path into the Spine UI and pressed enter. That is, a relative path is used if the images path is within 3 parents of the project folder. The parent folder of the JSON file is considered the project folder.
Sorry if that technical description seems a bit confusing. Maybe I should just show what the editor code does during import:
skeleton.imagesPath = skeletonData.getImagesPath();
if (skeleton.imagesPath == null) skeleton.imagesPath = projectDir;
if (!skeleton.imagesPath.exists()) {
var relative = jsonFile.parent().child(skeleton.imagesPath);
if (relative.exists()) skeleton.imagesPath = canonicalPath(relative);
}
skeleton.updateImagesPath(); // Makes the path relative if within 3 parents of the project path.
In plainer language, we don't have a way to set the images path explicitly. You'll want to move the JSON file into the project folder and import it from there. If you have exported your skeletons with nonessential data, that may be sufficient for your imported Spine projects to have the correct relative images path.
If there is no images path in your JSON, then your images path will be set to the project folder. If that is not what you want, you could modify the JSON to add the images path, possibly with a script. This will probably be difficult with a Windows batch script. With Cygwin you can write a Bash script and use Linux commands, so you could use sed
for example to replace text in a file:
sed 's/word1/word2/g' skeleton.json
You could replace skeleton: {
with skeleton: { images: "your/path",
. Really though, once your shell script starts getting complex, it may be better to change to an actual programming language, like Java, Perl, Python, or whatever you are most familiar with.