Skip to main content
Known Participant
Apr 12, 2011 7:18 PM UTC
Question

Renaming and copying files (Bridge CS3)

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 is closed to new replies. Start a new post to keep the conversation going.

3 replies

Muppet_Mark-QAl63s
Inspiring
Apr 12, 2011 8:28 PM UTC

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

Translate
jmw107Author
Known Participant
Apr 12, 2011 9:05 PM UTC

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.

Translate