# How to Batch Export All Directory Contents to PNG-8, Overwriting Existing Files?

Based on some preliminary manual testing, I've found that exporting as png-8 as one might expect provides significant file size reduction. One of my test images went from 58.8 kb to 10.7 kb.

With a delivery size of around 1 GB, my graphics package needs some trimming to make it play nicer, both with remote secured asset deliveries and for better performance in a low-storage embedded environment.

I want to roll this approach out to exporting all my images in my delivery to png-8. The problem is I have been unable to figure out how precisely to do that.

I tried record an action. I created a new action set, created new action w/ my template file open, select Quick Export to png-8 in the File > Export menu, I click save, click "Yes, overwrite existing file", then Ctrl+W to close. Stop recording.

When I try to run this action set on a directory of images, going to File > Automate > Batch, it opens them and closes them without saving.

If I select Save & Close in the circled box in the Batch dialogue, it seems to be saving them, but just as normal png files, not png-8:

It's interesting to note that my Export performed during the record period of the action does not seem to be noted in the Actions pane:

Expanding Close I see saving: no which is technically true... as I exported, not saved. But there's nothing there about the export.

My PS is PS CC cloud, version seen below (Windows 7, 64-bit):

How do I get the Batch process to:

1. Export to png-8.
2. Automatically confirm overwriting the existing png during this save process. (I will be always overwriting the existing copy.)

Thanks!

## 1 Answer

You need to use Export > Save for Web (Legacy) if you want to include it in an action. Neither the Quick Export, nor Export As can be included in an action, as of Photoshop CC 2017. This may change in future releases, but since these are still fairly new features, Adobe hasn't made them actionable yet probably to avoid issues with compatibility with older versions of Photoshop which don't have these new commands.

When you set up your Automate > Batch - make sure the source and destination folders are set up to the same folder. In the options check the Overide Action "Open" Commands, and Overide Action "Save as" Commands.

And now a warning: Make sure you are not editing your original PNG-24s. Work on a copy of the image folder, because once you have overwritten them, you will loose some alpha transparency and colour data that can't be undone by converting back to PNG-24.

• Perfect, testing this out now... and yes, ha! of course a copy. :) Glad you put the warning though for other who might use your answer. I believe it's more correct though to say "you may loose some alpha transparency and colour data, right" as that depends on whether your original image right, and whether you used more than 256 different color varieties. I have some small single color icons, for instance that use < 256 colors. Converting those is lossless. – Jason R. Mick Jun 29 '17 at 19:38
• Uh oh... my files won't work with this approach though. Save for web unlike Quick Export appears to force a matte. So this essentially throws out partial transparency values. So I'm not sure there's an option that works. – Jason R. Mick Jun 29 '17 at 20:29
• You can select Matte: "None" in the Save for Web dialog. But you will get a hard edge with PNG-8. It only has one level of transparency, like a GIF. – Billy Kerr Jun 29 '17 at 21:22