locked
Script to copy file name to title field.

    Question

  • Could anybody help me run John Beardsworth's script to copy the file name to the IPTC Title field.

    I have modified the script by replacing ivmp with ExpressionMedia as John says on his site, but I can't run the script on my test catalogue. In fact I can't get the script, saved as "filename to title" into the scripts menu.

    I am running XP Pro and the script has been put into the plugins/scripts folder as instructed.

    I'm obviously doing something wrong. Any advice?

    David
    Sunday, March 22, 2009 11:55 PM

Answers

  • Hi David,

    Because Notepad saves all files with txt extension by default, you have to enclose it in quotes when you save. Open it in Notepad again. Then save it as

    "filename to title.vbs"

    Be sure to put the quotes in or you will really get filename to title.vbs.txt, and it still won't work. Tricky but it works.

    Regards,
    Anita Oakley
    Microsoft Expression Media
    Monday, March 23, 2009 7:11 PM
    Moderator
  • Anita Oakley said:

    Because Notepad saves all files with txt extension by default, you have to enclose it in quotes when you save. Open it in Notepad again. Then save it as

    "filename to title.vbs"



    Alternatively, you can rename the file from an Explorer window.  Select the file and then either press F2 to edit the text, or right-click and choose Rename from the context menu.  Explorer will complain about changing the filename extension, but ignore the warning and change the filename so that it has a ".vbs" extension.  Re-launch Expression Media and the script should be visible in the script menu.

    -Matt
    Monday, March 23, 2009 7:51 PM
  •  
    judophotos said:


    However, the file name is created in the Product field instead of Title. The script is below.

    Could you tell me what to change in the script to put it in the Title.
     


    No, the script is correct.  The issue is that different organizations use different names for the same (meta)data.

    In your case, you have successfully updated the Title metadata, but the description of that metadata refers to it as Product.  The solution is to go into Edit->Preferences->General, and locate the combo box labelled "Field Names".  For you it probably has the value "Microsoft Expression Media".  Just change that to the value "IPTC Core", and all will be well.

    Cheers,
    Matt


    • Marked as answer by judophotos Monday, March 23, 2009 9:47 PM
    Monday, March 23, 2009 9:37 PM

All replies

  •  
    judophotos said:

    I have modified the script by replacing ivmp with ExpressionMedia as John says on his site, but I can't run the script on my test catalogue. In fact I can't get the script, saved as "filename to title" into the scripts menu.

    I am running XP Pro and the script has been put into the plugins/scripts folder as instructed.



    Do you have the correct directory?  It should be:

    <user>\Application Data\Expression Media 2\Plug-ins\Scripts

    where <user> is your WinXP home directory, something like:

    c:\Documents and Settings\Matthew Heaney

    So the full path to the scripts directory on my system is:

    c:/Documents and Settings/Matthew Heaney/Application Data/Expression Media 2/Plug-ins/Scripts

    Can you confirm whether you have the correct path to the plugins folder?

    Is the script file named correctly?  Does it have a .vbs or .js extension?

    -Matt

    http://home.earthlink.net/~matthewjheaney/damtools/

    Monday, March 23, 2009 4:19 PM
  • Thanks Matthew.

    The script is in the right directory but it is a text document and obviously wrong.

    How do I convert it to .vbs?

    David
    Monday, March 23, 2009 4:49 PM
  • Hi David,

    Because Notepad saves all files with txt extension by default, you have to enclose it in quotes when you save. Open it in Notepad again. Then save it as

    "filename to title.vbs"

    Be sure to put the quotes in or you will really get filename to title.vbs.txt, and it still won't work. Tricky but it works.

    Regards,
    Anita Oakley
    Microsoft Expression Media
    Monday, March 23, 2009 7:11 PM
    Moderator
  • Anita Oakley said:

    Because Notepad saves all files with txt extension by default, you have to enclose it in quotes when you save. Open it in Notepad again. Then save it as

    "filename to title.vbs"



    Alternatively, you can rename the file from an Explorer window.  Select the file and then either press F2 to edit the text, or right-click and choose Rename from the context menu.  Explorer will complain about changing the filename extension, but ignore the warning and change the filename so that it has a ".vbs" extension.  Re-launch Expression Media and the script should be visible in the script menu.

    -Matt
    Monday, March 23, 2009 7:51 PM
  • It worked!!!!!!

    Thank you very much both of you.

    However, the file name is created in the Product field instead of Title. The script is below.

    Could you tell me what to change in the script to put it in the Title.

    I am really grateful for your help.
    David


    '========================================================================================
    'by John Beardsworth 24/5/06
    'version 1.1
    'Loops through selected items and sets title field to same as filename  
    '========================================================================================

        Const kMsgBoxTitle = "Filename to title"

        Set ivApp = CreateObject("ExpressionMedia.Application")
       
        If (ivApp.Catalogs.Count = 0) Then
            MsgBox "Please launch Iview MediaPro.", vbCritical, kMsgBoxTitle
        else
            Main
        end if


    Sub Main()
        Set ivCat = ivApp.ActiveCatalog
        j=0   
        For Each ivItem In ivCat.Selection
        'ivItem.annotations.title = ivItem.name
        ivItem.annotations.title = left(ivItem.name, len(ivItem.name)-4)
        j = j + 1
        Next
    MsgBox j & " records updated", vbOKOnly, kMsgBoxTitle
      
    End Sub
    Monday, March 23, 2009 9:13 PM
  •  
    judophotos said:


    However, the file name is created in the Product field instead of Title. The script is below.

    Could you tell me what to change in the script to put it in the Title.
     


    No, the script is correct.  The issue is that different organizations use different names for the same (meta)data.

    In your case, you have successfully updated the Title metadata, but the description of that metadata refers to it as Product.  The solution is to go into Edit->Preferences->General, and locate the combo box labelled "Field Names".  For you it probably has the value "Microsoft Expression Media".  Just change that to the value "IPTC Core", and all will be well.

    Cheers,
    Matt


    • Marked as answer by judophotos Monday, March 23, 2009 9:47 PM
    Monday, March 23, 2009 9:37 PM
  • Well done Matt, you are absolutely right.

    Thanks very much.
    David
    Monday, March 23, 2009 9:46 PM
  • judophotos said:

        ivItem.annotations.title = left(ivItem.name, len(ivItem.name)-4)



    Hello David,

    I noticed the code above, which strips the extension from the filename (leaving only the "base" name).  You might want to avoid building intimate knowledge of filename syntax into the script.  For example, the code above assumes that the filename has exactly 3 characters, but this would break for different naming schemes, e.g. HTML files with a 4 or 5 letter extension, or MS Office XML-based docs that end in either .doc or .docx.

    One alternative is to use the File System Object, which encapsulates the knowledge that the operating system has about filenames.  So you could say:

    Dim objFSO
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    ...

    For Each item In items
       item.annotations.title = objFSO.GetBaseName(item.name)
    Next

    The file system object will do the right thing with the filename, no matter what the syntax of its extension is.

    Regards,
    Matt
    Monday, March 23, 2009 11:52 PM
  • I vote that the XM team hire Matt Heaney as a consultant.  He has solved several problems that were announced to be "unsolvable".

    Thanks Matt for all you have given us.


    Tuesday, March 24, 2009 12:04 AM
  • judophotos said:

    Could anybody help me run John Beardsworth's script to copy the file name to the IPTC Title field.


    Hello David,

    I have just uploaded the first public release of my Expression Media scripts, available from my website:

    http://home.earthlink.net/~matthewjheaney/damtools/

    For now it includes just a single script, Set Title From Name.vbs, which does the same thing as John's script, but with the difference that it uses my Progress Dialog object, allowing you to monitor execution of the script, or to cancel its execution.  The Progress Dialog object is also available from my website.  (Using the dialog object also helps to work around some idiosyncrasies of the Expression Media scripting engine, as explained in the README.TXT.)

    I have several scripts that I use for my workflow tasks (most of which customize the behavior of Expression Media), which I'll fold into the public release incrementally.

    -Matt

    keywords: Expression Media, scripts, IPTC, metadata
    Tuesday, March 24, 2009 2:16 AM
  • Hi Matt,

    Thanks for your help again. I have downloaded it and run it and it comes up with this message:

    ActiveX component can't create object: 'MJH.ProgressDialog'
    Src: Microsoft VBScript runtime error
    Line:44 Error:0 Scode:800a01ad

    Any ideas?
    David
    Tuesday, March 24, 2009 12:50 PM
  • judophotos said:

    Thanks for your help again. I have downloaded it and run it and it comes up with this message:

    ActiveX component can't create object: 'MJH.ProgressDialog'


    You need to install the progress dialog object before running the script.  (Note that installation only needs to be done once, unless you move the binary.)  That tool ("MJH Progress Dialog") is available at my website:

    http://home.earthlink.net/~matthewjheaney/damtools/

    The README has instructions about how to install it.  Drop me a line if you have any problems.

    -Matt

    keywords: progress dialog, expression media, scripts

     
    Tuesday, March 24, 2009 3:14 PM
  • Doobes said:

    I vote that the XM team hire Matt Heaney as a consultant.  He has solved several problems that were announced to be "unsolvable".

    Thanks Matt for all you have given us.




    That's very kind of you to say so.  I have more things in the pipeline, which I'll upload as I prepare them for public release.  (I think I have a solution for synchronizing labels among CaptureNX, Adobe Bridge, and Expression Media -- I'll post when I have something.)

    I don't know how much hiring Microsoft is doing these days (I think they had some lay-offs recently), but if you find my DAM tools useful, perhaps you would consider nominating me as a Microsoft MVP.

    -Matt

    keywords: Expression Media, scripts, metadata, xmp, nef
    Tuesday, March 24, 2009 3:24 PM
  • Thanks Matt. I'll install the script and let you know how I get on.
    David


    Tuesday, March 24, 2009 5:40 PM
  • Hello - 

    I am trying to do something very similar and could use a bit of hand-holding.
    I would like to copy the contents of EM's title field to EM's Product Field.

    I'm on a Mac, using EM2.

    1. I'm confused about where my scripts are located.  I just read (and found them) by opening the application program with Control, and I see them in Contents->Resources->zh_CN.scripts (and also in zh_TW.scripts).

    But I'm 99% sure that I had read about scripts being stored in another location as well, and I know I copied some into there but cannot find that location (which I'd like to clean out!).  Any idea what that other hard-to-find location is?

    2. I downloaded Matt's scripts, and copied the Set Title From Name.vbs into the Annotate folder that I found....  However, it doesn't appear within EM's pull-down menu; I assume that's because of the vbs extension

    3. What I'm really trying to do is copy from EM:Title to EM:Product; does that script exist?  If not, hopefully it won't be too difficult for to to alter the Set Title from Name script...

    Thank you - 
    Marion
    Monday, April 06, 2009 1:21 PM

  • 3. What I'm really trying to do is copy from EM:Title to EM:Product; does that script exist?  If not, hopefully it won't be too difficult for to to alter the Set Title from Name script...



    Title is the same thing as Product.  "Title" is the name that is assigned to that data field in the IPTC Core schema.  "Product" is the name that Expression Media uses.

    You can change the name of the field that is displayed in the info panel by going into the preferences diaglog box, and choosing a different value from the Field Names item.

    I don't have a Mac so I can't say why the script isn't showing up, but you're probably correct that VBS is not supported on the Mac.  I think JavaScript is, so maybe we just need to convert that script to JS.
    Monday, April 06, 2009 2:04 PM

  • 3. What I'm really trying to do is copy from EM:Title to EM:Product; does that script exist?  If not, hopefully it won't be too difficult for to to alter the Set Title from Name script...

    Hello Marion,

    I converted my Set Title From Name script to JavaScript, so it wil probably run on the Mac -- but you'll need to verify that.  (Does EM on the Mac only support AppleScript?)  Drop me a line if you're interested in the script.

    The only issue is that I used the Windows Shell to popup a dialog box for confirmations.  I doubt that will work on the Mac, but it would be easy enough to simply comment-out that code.  I can help you with the details of how to do that.

    -Matt
    Monday, April 06, 2009 5:50 PM