copy without overwriting

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

CaraLePoke

copy without overwriting

Post by CaraLePoke »

HI!

I'm trying to copy some files (reccursively) without overwriting files with the same name and increment the name.

I select a folder, with some other folder in it. I the folder and subfolders I have some EPS files I want to move to a target folder. Some EPS files have the same name and I want them not to be delete I want them incremented.


What I have:
SelectedFolder
-Folder1
FileA.eps
FileB.eps
-Folder2
FileC.eps
-Folder3
FileD.eps
FileA.eps
FileC.eps

What I'm tying to obtain with a script:
TargetFolder
FileA.eps
FileB.eps
FileC.eps
FileD.eps
FileA_1.eps
FileC_1.eps

I've done a script (using robohelp), but it don't make the incrementation.

Code: Select all#target photoshop
#include robohelp/file.jsxinc
#include robohelp/folder.jsxinc
app.bringToFront();
var SFolder = Folder.selectDialog( "Please select source folder");
var fileList = SFolder.getFiles("*.*");
copyRec(fileList);
alert("Endi!!");
function copyRec(fileList){
    for(var a in fileList){
        var name=fileList[a].name;
        if (isFile(fileList[a])){
            fileList[a].copy(File(SFolder + "/One4All/" + name));
        }else{
            if (fileList[a].name!="One4All"){
                copyRec(fileList[a].getFiles("*.*"));
                }
    }
        }
    }


Is there an instence of Copy that didn't overwrite?

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

Mike Hale

copy without overwriting

Post by Mike Hale »

One way to not overwrite files is to check if the file exists before coping.