The DAM Forum
Welcome, Guest. Please login or register.
August 21, 2014, 04:56:58 PM

Login with username, password and session length
Search:     Advanced search
28016 Posts in 5137 Topics by 2910 Members
Latest Member: kbroch
* Home Help Search Login Register
+  The DAM Forum
|-+  Software Discussions
| |-+  Scripting
| | |-+  Filename to Title Script change - removing "-"
« previous next »
Pages: [1] Print
Author Topic: Filename to Title Script change - removing "-"  (Read 2821 times)
chrisstitch
Newbie
*
Posts: 2


View Profile
« on: January 23, 2011, 05:29:09 AM »

Filename to title script is just what I've been looking for to title the 6,000 images on my web site.
They are all named "make-item-code.jpg" though and I would like to replace the "-" with a " ".

As it's my first time playing with JavaScript I'm finding it hard going!
I've tried butchering the script as below but I don't really know what I'm doing.
Can anyone help please?

Chris

for ( var i = 0; i < thumbs.length; i++ )
{ thumb = thumbs;

   md = thumb.synchronousMetadata;

   md.namespace ="http://ns.adobe.com/photoshop/1.0/";

   var thumb2 = thumb.replace(/\-/g," ");


   md.Title = thumb2.name;
   
}
Logged
johnbeardy
Administrator
Hero Member
*****
Posts: 1813


View Profile WWW
« Reply #1 on: January 23, 2011, 05:45:49 AM »

Chris,

This should help. It's a hack of one of the scripts at http://www.beardsworth.co.uk/lightroom/scripts-for-bridge/

In your code, you seem to be pointing to the thumbnail, then trying to parse it directly. In mine I show how I point to the thumb, then pull out its file name, then replace it.

John


Code:

f2xCommand .onSelect = function(m)
{
var getFolderChildren = true  ;
var filesOnly = true ;
var thumbs = app.document.selections;   

for ( var i = 0; i < thumbs.length; i++ )
{ thumb = thumbs[i];
   md = thumb.synchronousMetadata;
   md.namespace ="http://ns.adobe.com/photoshop/1.0/";
   var fileArray = thumb.name.split(".");

str = fileArray[0]
strNew = str.replace("_"," ")
                 md.Title =strNew ; 


}
   Window.alert ("Done " + i + " records");
};



Logged
chrisstitch
Newbie
*
Posts: 2


View Profile
« Reply #2 on: January 23, 2011, 12:57:21 PM »

John

The script replaced the first dash and even I could easily hack it to replace all the dashes.

It took me only 15 minutes to alter all the 6k images in their folders rather than a couple of days manually.

Many thanks,

Chris
Logged
amada
Newbie
*
Posts: 49


View Profile
« Reply #3 on: February 27, 2011, 09:06:06 PM »

Hello John:  does your script Set Filename to Title work with CS5 Bridge?  I tried to copy and paste it from CS4 and could not make it work. I sent you an email before discovering this thread in DAM FORUMS. Sorry.  Amada
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!