keep files from overwriting each other - file name as a random number?

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

sarahsmaths
Posts: 5
Joined: Sun Aug 01, 2021 6:30 am

keep files from overwriting each other - file name as a random number?

Post by sarahsmaths »

Hi everyone! I have been struggling with this problem for the last few weeks and I'm really at the end of my wits. I wonder if anyone might be able to give me a hand.

So I have this one folder called Export. I have created a macro in which every time you press a certain key, the document will be saved in that one folder, Export. The problem is, I cant seem to figure out an automated way to save multiple versions of the same file into that folder. Every time I try to save a new version with my action, it just overwrites the prior version. I would like to be able to save the same file many times and retain each copy in that same folder. I figure the best way to do this is to make it so that, instead of a document saving as the filename that's assigned to it, it saves as a random number. That way multiple versions will not overwrite each other. Is there a way to do this in photoshop? And if not, can anyone think of a solution to my problem? I just need my files to stop overwriting each other SOMEHOW. I cant use batch processing. Just trust me, heh. I've considered it, and it doesn't work as a solution. It's a long story. I can explain it if you want. The point is batch processing is a no go. Can anyone think of a way I can achieve what I'm looking for? Any help would be greatly appreciated!!
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: keep files from overwriting each other - file name as a random number?

Post by Kukurykus »

I have no idea why you can't use the batch. Maybe although that is long story explain it to find a workaround?

To save files with different names from same document, or different files using same action item you need Photoshop batch.

I assume you know what exact options you have to set in the batch so I don't have to instruct you about. That is no a problem, right?

The other solution is to write a script, however because of no time I won't do it for free. I may of course help you with batch for no cost ;)
sarahsmaths
Posts: 5
Joined: Sun Aug 01, 2021 6:30 am

Re: keep files from overwriting each other - file name as a random number?

Post by sarahsmaths »

Thanks! But the long story is this: I usually have like ten files open at a time. Exporting all open files simply does not fit into my workflow. I used to use an autohotkey script to export files. It would automate "save for web as png in folder: Export". Bam, you're done. All of this happened with the simple press of one button. I have found that doing this with ahk is slow and inefficient, and that doing it with a photoshop action was way way speedier. I am trying to recreate that same ahk experience with a photoshop action or script. I started with an action and it worked great. I would just press shift+F6 and photoshop would go file > save as current file name.png in folder: Export" and the file I would be working on would be instantly captured in it's current state, saved to my computer. That's what I want to do with the photoshop script. The action I created is ALLLLLLLLMOST perfect. The only problem is that I can't export the same file more than once. They just keep overwriting each other and I can't get them to stop. If I use batch, the image does not export with the simple press of a button and that is specifically what I am looking for. Otherwise it's not worth it to me. I might as well just save it manually. Also, I'm not looking to export ALL OPEN FILES. I'm only looking to export the current file I am working on in it's present state. Do you understand what I mean?

Thanks again for your help!
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: keep files from overwriting each other - file name as a random number?

Post by Kukurykus »

I have no problem with recording Save for Web action that saves only active document from many open to same location with its name as .png.

To do so, open some .psd, do not make any changes to, start recording action, open Save for Web, click "Save" button, choose location without giving any name to file, but leaving the one that you see, click Okay button and finally stop reroding. Now after you assign your Shift-F6 shortcut to the action the current file is going to be exported with its name as .png to a location specified in Action item without overwriting previous file.
sarahsmaths
Posts: 5
Joined: Sun Aug 01, 2021 6:30 am

Re: keep files from overwriting each other - file name as a random number?

Post by sarahsmaths »

Thanks for the suggestion! I would do that, but save for web is just way too slowwwww. if I'm going to do that, i might as well use autohotkey, which is a little bit faster. I wanted to use a Photoshop script to do - save as > name.PNG - because it's almost instant (that's what Im looking for) where as save for web takes 30 seconds or more :(
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: keep files from overwriting each other - file name as a random number?

Post by Kukurykus »

So why you won't use the same procedure while creating action for saving a file I described for Save for Web?
sarahsmaths
Posts: 5
Joined: Sun Aug 01, 2021 6:30 am

Re: keep files from overwriting each other - file name as a random number?

Post by sarahsmaths »

That's what I did originally. But when I do that, I can't export the same file more than once. If I export it a second time, it overwrites the prior version and that's not what I want. If I export it twice, I want to keep both versions.
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: keep files from overwriting each other - file name as a random number?

Post by Kukurykus »

I shared the instructions, did you try them, but for saving? Or you mean about exporting not different files but the same few times as well?
sarahsmaths
Posts: 5
Joined: Sun Aug 01, 2021 6:30 am

Re: keep files from overwriting each other - file name as a random number?

Post by sarahsmaths »

I did try it. That's what I started with. It just keeps overwriting the old file. I'm trying to export the same file over and over again with a different file name (somehow) each time. That's the part I'm struggling with. How to save each export as a different file name.
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: keep files from overwriting each other - file name as a random number?

Post by Kukurykus »

For me it works with no problem. I used the instructions I shared in other post but for saving .png. Using action then doesn't overwrite the file.

Edit: actually you are right. It doesn't resave the file, but only at first time. Then it resaves once saved copy. The solution is the script...