Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to rename files using Keywords?

Guest
Jan 24, 2022 Jan 24, 2022

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?

TOPICS
Batch , How to , Import and export , Keywords , Metadata
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 24, 2022 Jan 24, 2022

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 24, 2022 Jan 24, 2022

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 28, 2022 Jan 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:

1.png

 

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:

2.png

 

 

// 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;  
    }  
};  

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 28, 2022 Jan 28, 2022

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 28, 2022 Jan 28, 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"

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 29, 2022 Jan 29, 2022
LATEST

There are other considerations, like error checking (because a long string of keywords wouldn't be a legal filename, and keywords can have illegal filename characters) and serialization because keywords aren't unique identifiers, and what if dc: subject and photoshop:Keywords aren't the same, and such and so.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines