Skip to main content
delbermo
Participant
April 7, 2016
Question

2 file extensions?

  • April 7, 2016
  • 2 replies
  • 515 views

Hi,

I'm looking to save a file as the 'filename.jpg_DEL' and save to multiple folders using batch actions.

I'm familiar with batch actions and PS scripts but i cannot find a way to add this additional '_DEL' onto the extension through PS, it just saves as 'filename.jpg_DEL.jpg'

I'm using cc but im sure that doesn't really matter in this situation.

Im thinking a PS script could potentially achieve this but im not knowledgeable enough on creating scripts to achieve this

Would anyone have a solution? Any help/suggestions would be appreciated!

Thanks

Derek

This topic has been closed for replies.

2 replies

Stephen Marsh
Community Expert
Community Expert
April 9, 2016

A brute force approach would be to use Bridge’s Batch Rename tool:

MR74270
Inspiring
April 11, 2016

Hi all,

You can also adapt the following script. A recursive function can find all the JPEG images fond in the subfolders of a top folder and copy them with .jpg_DEL extension in the folders where the original documents are.

// Enables double clicking from the Macintosh Finder or Windows Explorer

#target docRefshop

app.bringToFront();

var message ="After launching this script on the top folder, you must wait.\r";

    message+="A message will inform you that the execution is finished.\r";

    message+="You will find a copy of your files with the extension .jpg_DEL\r";

    message+="in the folders where the original documents are. This can be\r";

    message+=" used as an example of recursive script.";

alert(message);

var saveOptions = new JPEGSaveOptions();

saveOptions.embedColorProfile = true;

saveOptions.formatOptions = FormatOptions.STANDARDBASELINE;

saveOptions.matte = MatteType.NONE;

saveOptions.quality = 10;

app.displayDialogs = DialogModes.NO;

var inputFolder = Folder.selectDialog("Select the top folder where your images are : ");

if (inputFolder != null) {

    filesArray = scanFolder(inputFolder);

    if (filesArray.length > 0)

    {

        for (i = 0;i<filesArray.length;i++)

        {

            var docRef = filesArray;

            app.open (docRef);

            var docName  = docRef.name;

            var docName  = docName.substring( 0, docName.indexOf('.') );

            var fileName = File(docRef.path+"/"+docName+".jpg_DEL");

            app.activeDocument.saveAs(fileName, saveOptions, true,Extension.LOWERCASE);

            app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

        }

    }

}

// Recursive function

function scanFolder(folder) {

    var filesArray = [],

    fileList = folder.getFiles(),i, file;

   

    for (i = 0; i < fileList.length; i++) {

        file = fileList;

        if (file instanceof Folder) {

            filesArray = filesArray.concat(scanFolder(file));

        }

        else if (file instanceof File && file.name.match(/\.(jpg|)$/i)) {

            filesArray.push(file);

        }

    }

    return filesArray;

}

// End of scripts

alert("Done !"); 

Inspiring
April 7, 2016

Check out ImageProcessorPro (ps-scripts - Browse /Image Processor Pro/v3_2 betas at SourceForge.net)

You can add '_DEL' to the end of the filename in the File Naming panel.