Skip to main content
Participant
May 13, 2022
Answered

Action to Save File with sequenced numbers

  • May 13, 2022
  • 2 replies
  • 2742 views

I would like to create an action that saves the .psd file I'm working on several times (without saving the .psd file) as a .jpeg with same name+number (next one, same name+next higher number) and so on. Any way to do this?

This topic has been closed for replies.
Correct answer Kukurykus

 

fN = (fls = File((aD = activeDocument).path).getFiles('*.jpg')
.sort(function(v1, v2) {return v1.modified < v2.modified})).length ? 
File(String(fls[0]).replace(/(\d+|)(?=\.jpg$)/i, function(_, v){return +v + 1}))
: aD.fullName, (jpg = new JPEGSaveOptions).quality = 12, aD.saveAs(fN, jpg, true)

 

2 replies

Kukurykus
KukurykusCorrect answer
Legend
May 13, 2022

 

fN = (fls = File((aD = activeDocument).path).getFiles('*.jpg')
.sort(function(v1, v2) {return v1.modified < v2.modified})).length ? 
File(String(fls[0]).replace(/(\d+|)(?=\.jpg$)/i, function(_, v){return +v + 1}))
: aD.fullName, (jpg = new JPEGSaveOptions).quality = 12, aD.saveAs(fN, jpg, true)

 

Stephen Marsh
Community Expert
Community Expert
May 13, 2022
Participant
May 13, 2022

Thank You!!
Nancy


[ private informations removed by moderator for security reasons ]

Stephen Marsh
Community Expert
Community Expert
May 13, 2022

Your welcome, please mark my reply as the correct answer if it closes off and resolves your original post/question.