Scripting in Windows batch files is extremely poor. It can be done, but it's very ugly and difficult to do even simple tasks. Cygwin can be used to run a script like what I linked on Windows.
yes true, i just want made a easy one click app.
But most of the program is write in js execute with node.
@echo off
title Spine Node Convertor (batch convert)
where node.exe >nul 2>&1 && echo Node detected || echo ERROR Node not detected , plz install it && pause && exit
NET SESSION >nul 2>&1
IF %ERRORLEVEL% NEQ 0 (
echo This setup needs admin permissions. Plz run this file as admin && pause && exit.
)
echo Admin permissions detected.
PING localhost -n 2 >NUL
echo.
cd %~dp0
node spineConvertor.js %~dp0
cmd /k
And node js part:
const path = require('path');
const fs = require('fs' );
const { exec } = require('child_process');
const readline = require('readline')
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})
let SPINE_EXE = null;
let VERSION = null;
let ROOT = process.argv[2];
console.log(process.versions);
console.log('\x1b[33m%s\x1b[0m',`\nROOT PROJECT: ${ROOT}\n`);
const q1 = () => {
return new Promise((res, rej) => {
console.log('\x1b[32m%s\x1b[0m',`Enter Spine install directory?`);
rl.question(' By default is: "C:\\Program Files (x86)\\Spine"\n if default leave empty.\n', (dir) => {
SPINE_EXE = dir && dir+"\\Spine.com" || "C:\\Program Files (x86)\\Spine\\Spine.com";
console.log('\x1b[33m%s\x1b[0m',`SPINE_EXE: [ ${SPINE_EXE} ] Asigned!\n`);
res();
});
})
}
const q2 = () => {
return new Promise((res, rej) => {
console.log('\x1b[32m%s\x1b[0m',`Enter Spine version for exporter.`);
rl.question(` Example:\n 3.8.13-beta 'default'\n 3.8.11-beta\n 3.7.9\n 3.7.8\n`, (ver) => {
VERSION = ver || '3.8.13-beta';
console.log('\x1b[33m%s\x1b[0m',`Version: [ ${VERSION} ] Asigned!\n`);
res()
})
})
};
const scan = () => {
return new Promise((res, rej) => {
console.log('\x1b[32m%s\x1b[0m',`SCANNING SPINES PROJECT FILES IN SUB DIRECTORY`);
let data = {};
let fromDir = (startPath,filter)=>{
if (!fs.existsSync(startPath)){ return console.log("no dir ",startPath) };
let files=fs.readdirSync(startPath);
for(let i=0;i<files.length;i++){
let filename=path.join(startPath,files[i]);
let stat = fs.lstatSync(filename);
if (stat.isDirectory()){ fromDir(filename,filter) } //recurse
else if (filename.indexOf(filter)>=0) {
let filenameFormated = filename.replace(/\\/g, "/");
let dirArray = filenameFormated.split("/"); // repertoire path formated for array [,,,]
let fileData = path.parse(filenameFormated); // split data
dirArray.pop();
fileData.dirArray = dirArray;
fileData.root = `${fileData.dir}/${fileData.base}`
data[fileData.name] = fileData;
console.log('\x1b[33m%s\x1b[0m',`FOUND: [ ${fileData.base} in ${fileData.dir} ]\n`);
};
};
};
fromDir('data2','.spine'); //START: startPath, extention.Filter
setTimeout(() => {
console.log('SCAN RESULT: ', data,'\n\n');
console.log('\x1b[32m%s\x1b[0m',`Check if files look fine?`);
rl.question(` Enter (y) to continue\n`, (fileOk) => {
fileOk==='y' && res();
console.error('Fix your files and restart');
});
}, 500);
});
};
const main = async () => {
await q1()
await q2()
await scan()
test()
rl.close()
}
main()
function test() {
console.log('\x1b[33m%s\x1b[0m',`test::: "${SPINE_EXE}" -u ${VERSION}\n`);
var dir = 'C:\\Users\\InformatiqueLepage\\Documents\\Dev\\anft_1.6.1';
exec(`"${SPINE_EXE}" \ -u ${VERSION} -i ${ROOT}\\data2\\Characteres\\a1\\SOURCE\\a1.spine`,
(err, stdout, stderr) => {
if (err) { return console.log('err: ', err) && console.log('stderr: ', stderr) };
console.log(`stdout1: ${stdout}`);
});
};
.
Where settings.json is the settings to do the export you want.
The export settings JSON file is created using Spine by clicking on the Save button at the bottom of the Export dialog
haaa i see, thanks i think i understand now.
I thought he was taking the default setting of the project?
i will give a try , thanks you so much for your time.
EDIT:
hum...
i get a error with with the basic json
Spine Launcher 3.7.91
Esoteric Software LLC (C) 2013-2019 | http://esotericsoftware.com
Windows 10 Enterprise x86 10.0
Spine 3.8.13-beta Professional
ERROR: Error reading export settings file:
C:/Users/InformatiqueLepage/Documents/Dev/anft_1.6.1/setupExport.json
java.lang.RuntimeException: Unknown object type: class il
at com.esotericsoftware.spine.editor.export.ExportSettings.a(SourceFile:60)
at mG.<init>(SourceFile:79)
at com.esotericsoftware.spine.editor.Editor.main(SourceFile:1515)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at tzax.B.run(SourceFile:2030)
at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.desktop/java.awt.EventQueue.access$600(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.desktop/java.awt.EventQueue$4.run(Unknown Source)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)
it put a copy past from the example in setupExport.json
{
pot: true,
paddingX: 2,
paddingY: 2,
bleed: true,
edgePadding: true,
duplicatePadding: false,
rotation: false,
minWidth: 16,
minHeight: 16,
maxWidth: 1024,
maxHeight: 1024,
square: false,
stripWhitespaceX: false,
stripWhitespaceY: false,
alphaThreshold: 0,
filterMin: Nearest,
filterMag: Nearest,
wrapX: ClampToEdge,
wrapY: ClampToEdge,
format: RGBA8888,
alias: true,
outputFormat: png,
jpegQuality: 0.9,
ignoreBlankImages: true,
fast: false,
debug: false,
combineSubdirectories: false,
flattenPaths: false,
premultiplyAlpha: false,
useIndexes: true,
grid: false,
scale: [ 1 ],
scaleSuffix: [ "" ],
limitMemory: true,
ignore: false
}
but i also try with double quote, same...
i forget something ?
the full command seem ok:
"C:\Program Files (x86)\Spine\Spine.com"
-u 3.8.13-beta
---
input C:\Users\InformatiqueLepage\Documents\Dev\anft_1.6.1\data2\Characteres\a1\SOURCE\a1.spine
---
output C:\Users\InformatiqueLepage\Documents\Dev\anft_1.6.1\test
---
export C:\Users\InformatiqueLepage\Documents\Dev\anft_1.6.1\setupExport.json
EDIT.
OK WORKING
you need export from spine , the demo page are wrong.
like you say here, this working fine.
Export PNG preview from command line