Copy link to clipboard
Copied
Hi -- Scripting bridge, I am able to copy files using the copyTo(target) function.
I also can rename files using the Javascript file.rename() function.
But I am having trouble doing both in concert.
If I rename before I copy, I lose the reference to the selected thumb, and I cannot copy it.
I have tried using the Javascript file.copy() function with no success.
Does anyone have any suggestions how I can approach this problem?
thanks in advance
Copy link to clipboard
Copied
Don't you just need to cancat the folder that you have as target and the thumbs name in a new file object?
#target bridge var thisFolder = Folder.desktop; var thisFile = app.document.selections[0]; if (thisFile.type == 'file') { if (thisFile.copyTo(thisFolder)) { var newFile = File(thisFolder.fsName + '/' + thisFile.name); newFile.rename('SomeNewName'); } }
Copy link to clipboard
Copied
Hi -- Thanks -- that's what I needed.
... but I did run into one issue: The renaming of the file does not work when my target directory is a network location as opposed to a local folder. Is there a workaround for that?
thanks again for your assistance.
Copy link to clipboard
Copied
Ahhh .. nevermind. I figured it out. No need for .fsName for network location.
thanks again