[command] Batch save files contained in a folder

Hi all,

I’m executing this command in a bat file :

@set ASEPRITE=“C:\Program Files (x86)\Steam\steamapps\common\Aseprite\aseprite.exe”
%ASEPRITE% -b D:\PATH_LOAD\sprite.ase --save-as D:\PATH_SAVE{tag}_01.png

But I’d like to execute it for all the *.ase files located in my PATH_LOAD folder (including subfloder).
I don’t know much about CMD features, I gave some FOR logic a go without any success.

Could someone give me a hand on that one ?


You can try some of these solutions, anyway I would recommend you to use a Bash script which are easier to program (generally all Git distributions for Windows include some kind of Bash interpreter), where you can do something like:

aseprite=“C:/Program Files (x86)/Steam/steamapps/common/Aseprite/aseprite.exe”
for file in D:/PATH_LOAD/*.ase ; do
  $aseprite -b $file --save-as D:/PATH_SAVE/{title}_{tag}_01.png

Thanks, I’ve seen the solutions you sent me. That’s what I failed to use.
Do the Bash script is usable in a bat file ?

You will need an extra .sh script and call it with a bash interpreter from the .bat file:

"C:\some place where bash is located\bash.exe" other_script.sh

Generally I make all scripts directly on bash language and then call them from the command line using bash script name (without a .bat, but you can use a .bat to double-click it from the Windows Explorer)

Thanks, you’re fast :slight_smile:

That’s a good idea. I’m trying to do as in your example but I don’t know why it doesn’t work.
I made a script.sh file with that inside :

aseprite=“C:/Program Files (x86)/Steam/steamapps/common/Aseprite/aseprite.exe”
for file in D:/PATH_LOAD/*.ase ; do
$aseprite -b $file --save-as D:/PATH_SAVE/{title}_{tag}_01.png

But nothing seems to happen. I don’t get what I’m doing wrong.

How are you executing the script? What is the output in the console/terminal?

I tried to run it through the Git Bash command prompt. Here’s what happened. (I’m pasting the whole thing)

$ aseprite=“C:/Program Files (x86)/Steam/steamapps/common/Aseprite/aseprite.exe”

$ for file in D:/PATH_LOAD/*.ase ; do

$aseprite -b $file --save-as D:/PATH_LOAD/{title}_{tag}_01.png

Then, it just stayed there doing nothing else.

And I also tried to put it in a sh file and launch it by double clicking on it (I’m improvising here…).
I’m very new to this.

My mistake, the final word is not end, is done (editing my original reply right now).

it went a little bit further this time.
but it ended with this :

bash: C:/Program: No such file or directory

And it did nothing.

Try using "$aseprite" to call Aseprite.

Thank you for taking the time. That’s nice to take care of newbie :slight_smile:

I tried using $aseprite instead of the whole path, I tried to add it in front of the path… I tried several other thing, but this is what I got most of the time :

bash: -batch: command not found

Let me copy a new version of the script:

aseprite=“C:/Program Files (x86)/Steam/steamapps/common/Aseprite/aseprite.exe”
for file in D:/PATH_LOAD/*.ase ; do
  "$aseprite" -b $file --save-as D:/PATH_SAVE/{title}_{tag}_01.png

(Sorry for the back and forth about this but I’m not on Windows right now to give a try :sob:)

Don’t be sorry, you’ve been very helpful (even in the past).
It works great now. Thanks a lot.

Now I’m trying to “include” it inside of my bat file but I’m kinda stuck.
I tried to add what you suggested earlier :

“C:\Program Files\Git\git-bash.exe” script.sh

and added what we’ve been muddling through in the script.sh.

But nothing happened.

1 Like


“C:\Program Files\Git\git-bash.exe” -c script.sh

could work, but I’m not sure, or

“C:\Program Files\Git\git-bash.exe” -c "bash script.sh"

I ended up doing the script with bash only. It seems indeed easier to work with.
Right now I’m trying to make an if statement inside a for loop to batch all the *.ase of a folder except for one that I want to save in a different manner.

Does it look remotely like something that could work at some point ?

for file in D:/00_TAKROG/SPRITES/CHARACTERS/*.ase ; do
if [ ${file: -4} == “items.ase” ]; then
“$aseprite” -b --split-layers D:/00_TAKROG/ATLAS_UNIT_AND_DOODADS/items.ase --save-as D:/00_TAKROG/ATLAS_UNIT_AND_DOODADS/{tag}_01.png

We found the solution for the if statement. But something odd happens If I execute this code :

aseprite=“C:/Program Files (x86)/Steam/steamapps/common/Aseprite/aseprite.exe”
## "Characters" avec exception "Items"
for file in D:/00_TAKROG/SPRITES/CHARACTERS/*.ase ; do
	if [[ "$(basename -- "$file")" == "items.ase" ]]; then
	  "$aseprite" -b --split-layers $file --save-as D:/00_TAKROG/ATLAS_UNIT_AND_DOODADS/{tag}_01.png
	  "$aseprite" -b $file --save-as D:/00_TAKROG/ATLAS_UNIT_AND_DOODADS/{tag}_01.png

The --split-layers function is ignored.
But I know this command works in that context because I used it in CMD, when I was using a bat file.

Hi @J-A_C, I think the issue here is that the filename (D:/00_TAKROG/ATLAS_UNIT_AND_DOODADS/{tag}_01.png) is missing a {layer} part (so each layer goes to a different filename). For example:

"$aseprite" -b $file --save-as D:/.../{layer}{tag}_01.png

(The --split-layers is automatically done when the filename specified in --save-as contains {layer})

YES ! That works :smiley:
Thank you so much !

You’re welcome! :blush:

My bash script works like a charm. But there one thing I’d like to do is make my script.sh clickable, and for some reason, every command works except the one using aseprite.

Every command before

aseprite=“C:/Program Files (x86)/Steam/steamapps/common/Aseprite/aseprite.exe”

works, but the rest just doesn’t do anything.
Is it even possible to do it ?