Skip to main content
Gibson Editions
Inspiring
June 15, 2021
Answered

Refresh filename/ path halfway through script

  • June 15, 2021
  • 2 replies
  • 496 views

I have a script that renames files and then passes them across to photoshop. 

the only problem being that it doesnt update the filenames, so the photoshop script cant open the renamed files.

How do i refresh the filenames/ paths of a selection in bridge

 i see something called refreshInfoset() in the bridge SDK but cant get it working. 

//this is the thumbnail object im trying to refresh
sel1[0].core.immediate.name

 

This topic has been closed for replies.
Correct answer Lumigraphics

If you are renaming files, you already have the new filename in a variable, right? Otherwise use thumbnail/spec as the object and get one of the several name properties.

2 replies

Legend
June 15, 2021

Here is a script that doesn't use filenames. So you should be able to rename selections and then pass the files to PS. I have not tested renaming, however.

 

/*
Utility Pack Scripts created by David M. Converse ©2018-21

This script allows opening files directly into Photoshop, bypassing ACR

Last modified 6/7/2021

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

APACHE LICENSE, VERSION 2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#target bridge
if(BridgeTalk.appName == "bridge"){
var openCommand = MenuElement.create('command', 'Open Directly', 'after Thumbnail/Open', this.menuID); //add to Contextual menu
}

openCommand.onSelect = function(){
openDirect();
}

function openDirect(){
try{
var t = app.document.selections;
var files = new Array();
for(var i = 0;i < t.length;i++){
if(t[i].spec instanceof File){
files.push(t[i].spec);
}
}
if(files.length > 0){
var scr = "var thumbs = eval(" + files.toSource() + "); for(var i = 0; i < thumbs.length;i++){photoshop.open(new File(thumbs[i]));}";
var bt = new BridgeTalk();
bt.target = 'photoshop';
bt.body = scr;
bt.onError = function(eObj){ retval = false; $.writeln(eObj.body); }
bt.send();
}
else{
alert('No files chosen.');
retval = false;
}
return retval;
}
catch(e){
}
}

LumigraphicsCorrect answer
Legend
June 15, 2021

If you are renaming files, you already have the new filename in a variable, right? Otherwise use thumbnail/spec as the object and get one of the several name properties.

Gibson Editions
Inspiring
June 15, 2021

That's a fair point that did the trick! Many thanks for the script as well useful to see 

Legend
June 16, 2021

I have a bunch of scripts and tools on my Dropbox, all open source.

Adobe Scripts