Skip to main content
Known Participant
April 12, 2011
Question

Renaming and copying files (Bridge CS3)

  • April 12, 2011
  • 1 reply
  • 1024 views

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

This topic has been closed for replies.

1 reply

Muppet_Mark-QAl63s
Inspiring
April 12, 2011

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');            } }

jmw107Author
Known Participant
April 12, 2011

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.