Hi,
Many years ago I received help from someone on a forum very much like this one.
My request was for a script to copy the filename of an image and write it into the "File Info"
My habit was to open an image, process/retouch it and save the file with a more meaningful name, rather than the camera filename.
I obtained said script and over the years it proved very valuable as I could go to File Info and find the file name of the original image. This means that I can find the file to reprocess without trying to remember which shoot out of almost 20 years of images in my archive.
So, Can someone please help me by recreating this script that I have lost during some computer upgrade or other over the past couple of years.
TLDR;
I'd like a script to write the current filename into either the Document Title or Description in the Basic tab in File Info
Thanks in advance
Kenny
Script to add filename to file info?
Re: Script to add filename to file info?
'PreservedFileName' field is more correct for original name. It can be obtained from File Properties in Raw Data of XMP Metadata.
Write to:
Read from:
Write to:
Code: Select all
!ExternalObject.AdobeXMPScript && ExternalObject
.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
(meta = new XMPMeta((xmp = (aD = activeDocument).xmpMetadata).rawData))
.setProperty('http://ns.adobe.com/xap/1.0/mm/', 'PreservedFileName',
aD.name), xmp.rawData = meta.serialize()
Code: Select all
!ExternalObject.AdobeXMPScript && ExternalObject
.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
(meta = new XMPMeta((activeDocument.xmpMetadata).rawData))
.doesPropertyExist(ns = 'http://ns.adobe.com/xap/1.0/mm/',
pm = 'PreservedFileName') && meta.getProperty(ns, pm).value
Re: Script to add filename to file info?
Wow, thank-you Kukurykus.
I wonder if you can advise me how to make use of these scripts.
I have almost zero knowledge of scripting
Thanks
Kenny
I wonder if you can advise me how to make use of these scripts.
I have almost zero knowledge of scripting
Thanks
Kenny
Re: Script to add filename to file info?
The same as you used previous scripts? Save these codes to separate .jsx files, one as Reader, second as Writer. You may then copy them to 'Presets / Scripts' folder of your Photoshop, so after relaunching the application you'll have access to them from 'File / Scipts' menu.
Re: Script to add filename to file info?
Another method, might be a bit cleaner depending on how you implement it:
Code: Select all
app.activeDocument.info.title = app.activeDocument.name; //Adds the current document name to the IPTC Core field "Title"
app.activeDocument.info.caption = app.activeDocument.name; //Adds the current document name to the IPTC Core field "Description"
//Then when you're done:
app.activeDocument.close(SaveOptions.SAVECHANGES);
Re: Script to add filename to file info?
This is what he asked for indeed, but I avoided to provide this method as it was used due to lack of his knowledge of something more appropriate.
Re: Script to add filename to file info?
You can also, instead of placing the .jsx-files in your "Presets/Scripts"-folder in Photoshop, just place them wherever and create an action that you name to "Reader", then select "Record", File > Scripts > Browse..., and then select the .jsx-file. Then stop the recording, and play the action again whenever you want to play the script.Kukurykus wrote: ↑Thu Aug 25, 2022 9:01 am The same as you used previous scripts? Save these codes to separate .jsx files, one as Reader, second as Writer. You may then copy them to 'Presets / Scripts' folder of your Photoshop, so after relaunching the application you'll have access to them from 'File / Scipts' menu.
That's a good reason. However if anyone else with more knowledge faces the same problem, I don't see any problem with providing them with more solutions:)