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?
copy without overwriting
-
Mike Hale
copy without overwriting
One way to not overwrite files is to check if the file exists before coping.