Skip to main content
avi123123
Participant
April 19, 2018
Question

Add date to save as action

  • April 19, 2018
  • 1 reply
  • 247 views

Hi

I created an action that saves my work as tif file.

as I worked with the same file all the time I want to add date / or sequence number so it won't overwrite my saved file.

I see it in the batch option the problem is the batch run on all open files or folder and close the files.

Any Ideas

Thank you

This topic has been closed for replies.

1 reply

JJMack
Community Expert
Community Expert
April 19, 2018

If you look at Adobe Image process script you will see it does not overwrite existing files. If the output file to be saved exist a sequence nunber is appended to the file name to make the output file unique.

///////////////////////////////////////////////////////////////////////////////

// Function: CreateUniqueFileName

// Usage: Given a folder, filename, and extension, come up with a unique file name

// using a numbering system

// Input: string for folder, fileName, and extension, extension contains the "."

// Return: string for the full path to the unique file

///////////////////////////////////////////////////////////////////////////////

function CreateUniqueFileName( inFolder, inFileName, inExtension ) {

inFileName = inFileName.replace(/[:\/\\*\?\"\<\>\|]/g, "_");  // '/\:*?"<>|' -> '_'

var uniqueFileName = inFolder + inFileName + inExtension;

var fileNumber = 1;

while ( File( uniqueFileName ).exists ) {

uniqueFileName = inFolder + inFileName + "_" + fileNumber + inExtension;

fileNumber++;

}

return uniqueFileName;

}

JJMack