Skip to main content
January 24, 2022
Question

How to rename files using Keywords?

  • January 24, 2022
  • 2 replies
  • 1552 views

How to rename files using Keywords?
For example, I have 10 files with a 1080 key, 10 files with a 47434 keyword, and 10 more files with a 9484 keyword.
Can I rename these files to 1080_1, 1080_2... up to 1080_10,
47434_1...47434_10
There is no choice of Keyword in Batch Renaming, maybe there is another option?

This topic has been closed for replies.

2 replies

Stephen Marsh
Community Expert
Community Expert
January 28, 2022

Ideally a custom script would do this in one step.

 

A multi-step process using existing scripts would be:

 

1) Use a script to copy keywords to description or title, which is supported by the batch rename metadata field. Scripts below. Info on how to save and install them here:

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

2) Rename using the accessible title or description metadata:

 

3) Use a string substitution regex find/replace to remove the auto numbering that is produced when duplicate files clash with the same name and replace with a sequence number:

 

 

// https://forums.adobe.com/thread/1223292
// https://forums.adobe.com/thread/2318450
#target bridge     
if( BridgeTalk.appName == "bridge" ) {    
keysToDescription = MenuElement.create("command", "Keywords To Description", "at the end of Tools");  
    }  
keysToDescription.onSelect = function () {   
var sels = app.document.selections;  
for(var a in sels){  
md =sels[a].synchronousMetadata;   
md.namespace = "http://ns.adobe.com/photoshop/1.0/";   
var Keys =  md.Keywords.toString().replace(/,/g,', ');// Replace a comma with comma space  
md.namespace = "http://purl.org/dc/elements/1.1/";  
md.description ='';  
md.description = Keys;  
    }  
};  

 

 

 

// https://forums.adobe.com/thread/1223292
#target bridge     
if( BridgeTalk.appName == "bridge" ) {    
keysToTitle = MenuElement.create("command", "Keywords To Title", "at the end of Tools");  
    }  
keysToTitle.onSelect = function () {   
var sels = app.document.selections;  
for(var a in sels){  
md =sels[a].synchronousMetadata;   
md.namespace = "http://ns.adobe.com/photoshop/1.0/";   
var Keys =  md.Keywords.toString().replace(/,/g,', ');// Replace a comma with comma space  
md.namespace = "http://purl.org/dc/elements/1.1/";  
md.title ='';  
md.title = Keys;  
    }  
};  

 

Legend
January 28, 2022

Keywords are in dc:subject, other namespaces such as photoshop, lr, and exif are optional.

Stephen Marsh
Community Expert
Community Expert
January 29, 2022

I tried hacking the following script without much success:

 

https://www.ps-scripts.com/viewtopic.php?f=72&t=14282&p=89792&hilit=rename#p89787

 

It's very easy with ExifTool, here using a regular expression to replace comma/space with a hypen (depending on the keyword separators this may be a semi-colon with or without a space etc). One must be careful that filenames don't include invalid characters.

 

Mac OS:

exiftool '-FileName<${subject;s/, /-/}.%e' '/path to/file or/folder'

 

Win OS:

exiftool "-FileName<${subject;s/, /-/}.%e" "\path to\file or\folder"

 

Legend
January 24, 2022

You would have to use a script that reads keywords and renames files accordingly.

January 25, 2022

can you tell me where I can find a script or a specialist who can write it?