Skip to main content
Known Participant
December 27, 2017
Answered

Please help.....

  • December 27, 2017
  • 3 replies
  • 77911 views

I have lots of images with file names like this, Jaroslav_Krej%C4%8D%C3%AD.jpg,

I am trying to copy the file name to the image caption.

Is there a way to do this and replace the special characters with their correct ones and can i do this in a batch.

I'm very new to this and its driving me crazy

Thanks very very much in advance

This topic has been closed for replies.
Correct answer Kukurykus

Okey, later when I remove bugs we'll do easy test to see any menu loaded to Bridge is present at it's place...

EDIT:

Save it as Item.jsx on your (& run from) desktop (paste to noteapd & then saving insert a name into dbl quotes: "Item.jsx"):

#target bridge

new MenuElement("command", "Item", "at the end of Thumbnail")

When you click with right mouse button on any folder/file or even outside in the 'Content' area you will see a list of default items (commands) starting with "Open" and then other like "Paste", "Cut" etc. At the bottom of this list you should see new item, named "Item". I checked 2018 Bridge documentation and menu / commands section is alike CS 6 version. Perhaps you must allow this script to be loaded each time at start of Bridge. Edit/Preferences/StartupScripts. Then find checkbox for Item and check it (don't forget to tell me that was there in case script still won't be working). Then reopen Br and script should be loaded.  If not, check again that SS section. If there is not script listed then maybe it's not in proper Startup Scripts folder. But if you copied before it to in and then at startup of Bridge you got that error you posted a screen of it means Br detected this script for sure inside a folder that should be put in. Anyway, below is the newest VERSION IIof script for you:

#target bridge

NtC = new MenuElement("command", "Name \

to Caption", "at the end of Thumbnail")

NtC.onSelect = function() {

     function rec(sF, dst, i) {

          if (fld = io(sF)) sF = sF.getFiles(); for(; i < sF.length; i++) {

               if (io(fof = sF)) dst.push(fof.name), rec(fof, dst, 0)

               else if(/.jpg$/i.test(fof)) {

                    function reg(v) {return v.replace(/_/g, ' ')}

                    ns = 'http://ns.adobe.com/photoshop/1.0/';

                    (md = new Thumbnail(fof).synchronousMetadata).namespace = ns

                    md.Caption = (spc = reg((nme = decodeURI(dec = decodeURI(fn = fof.name))))).slice(0, -4)

                    I = 0; while(nme != dec && fn == fof.name && I < 5) $.sleep(50), I += !fof.rename(spc)

               }

          }

          return dst

     }

     function io(v) {return v instanceof Folder}

     if ((sel = app.document.selections[0])

     && io(spec = sel.spec)) rec(spec, [], 0)

}

When you copy it to notepad DON'T FORGET to remove additional white spaces from after slash at end of second line!

This script browses entire content of selected folder, so all deepest nasted subfolders with all jpg images. Do not select more folders at once  however only (first ?) one will be processed. It adds to description field name of file without extension, and change name of file to decoded. Both, that field and name of each file gets new name, where underscores are replaced with spaces, while all URL characters decoded. When in the same folder there is already a file with a desired name for source file then source one won't be changed to new version. It only will get new name in description field.

I tested it on hundrets files with different names and several folders, also with desired names for source files in range of one folder, and it worked well. You had to wait approximately about 10 mins with frozen Bridge if you ran process for 6000 files.

Even if you had only to change every file to the same name (however you can't have in the same folder same named files) and then quickly opened metadata panel to paste that name in as well, you'd spend about 15 hours working with very rapid tempo, and without making even one second breaks.

If you had additionally to change names to decoded ones by some application translator (where you put encoded name to get decoded) then again pasted it to file and description field that had to take 30 hours. Doing it totally manually (having in brain all URI codes with their equivalents) probably 50 hours. When checking each URI character in dictionary before you remember them all meantime that could be 120 hours so about 5 days (including nights), and all without eating, sleeping and geting up from a chair, with hands constantly having on keyboard while head directed to buring your eyes screen

3 replies

Kukurykus
Legend
December 28, 2017

Copy it to Adobe Startup Scripts folder, so 'C:\Program Files\Common Files\Adobe\Startup Scripts CS6\Adobe Bridge' (in case of Ps CS6), and then reopen Bridge. Right click on the folder containing (subfolder with) images where (some) have wrong names and select last time from the commands list: "Name to Caption". Aditionally all your encoded file names are going to get decoded! This functionallity will be always available in your Bridge as far as you keep the Name to Caption.jsx script in mentioned folder.

#target bridge

NtC = new MenuElement("command", "Name to Caption", "at the end of Thumbnail")

NtC.onSelect = function() {

     function FSf(sF, dst, i) {

          function io(v) {return v instanceof Folder}

          if (fld = io(sF)) sF = sF.getFiles()

          for(; i < sF.length; i++) {

               if (io(fof = sF)) dst.push(fof.name), FSf(fof, dst, 0)

               else if(/.jpg$/i.test(fof)) {

                    (md = new Thumbnail(fof).synchronousMetadata)

                    .namespace = 'http://ns.adobe.com/photoshop/1.0/'

                    md.Caption = (nme = decodeURI(decodeURI(fof.name)))

                    .slice(0, -4); if(!(nme == fof.name)) sF.rename(nme)

               }

          }

          return dst

     }

     FSf(app.document.selections[0].spec, [], 0).join('\n')

}

Btw there are 2 bugs (when you don't click on folders and that sometimes renaming may work too fast) later I'll fix.

Known Participant
December 28, 2017

Hi, Thanks for the script but i'm getting an error.

Kukurykus
Legend
December 28, 2017

Later I changed code I posted originally but I see you used that previous. You can remove white spaces characters which are after slash '\' and then save code again or just use newer one with corrected part. But the best will be if you copy a code you have in my previous post. Remember there are 2 bugs later I'll fix. It's not hard, but I'm at work right now.

NtC = new MenuElement("command", "Name to Caption", "at the end of Thumbnail")

Stephen Marsh
Community Expert
Community Expert
December 28, 2017

paulf58498760 you mention the “caption” metadata field, which is actually a legacy label, this is currently known as “description”. The topic thread that SuperMerlin pointed you to is labeled “title”, however the actual metadata field that the script populates is the “description”.

This script only removes the filename extension… However you also mention other special characters that need to be removed, so two questions:

1) Which special characters? Is it just the underscore _ and only the percentage sign % or is it also the letter and digit with the % sign? Can you provide samples of more than one filename and the required result so that the forum can be sure that the pattern is consistent?

Jaroslav_Krej%C4%8D%C3%AD.jpg

Jaroslav Krej C4 8D C3 AD

Jaroslav Krej

2) Do you also wish to remove the special characters from the filename, or leave the filename alone and only remove the special characters from the description metadata field?

Known Participant
December 28, 2017

Thanks for the replys

Yes sorry the Description field is where I'm trying to move the data.

I'm trying to convert the special characters as per the link bellow and the examples after, yes I want to swap the underscore for a space and remove the .jpeg bit.

http://www.fileformat.info/info/charset/UTF-8/list.htm

Before and after examples :-

Marie_Sklodowska,_%C3%A9tudiante,_en_1895.jpg   -   Marie Sklodowska, étudiante, en_1895

Miko%C5%82aj_Rey.jpg                                               -  Mikołaj Rey

Some file names have more than 1 group of special characters.

I hope this helps.

Again thanks very much for all your help

SuperMerlin
Inspiring
December 28, 2017

See the answer in this thread...

How to Batch copy filename to its metadata Title