# Rename using Custom Data for human being

**URL:** https://discourse.devontechnologies.com/t/rename-using-custom-data-for-human-being/69820
**Category:** DEVONthink
**Tags:** automation
**Created:** [February 26, 2022, 10:31pm UTC](https://discourse.devontechnologies.com/t/rename-using-custom-data-for-human-being/69820 "2022-02-26T22:31:41Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![pete31](https://discourse.devontechnologies.com/letter_avatar_proxy/v4/letter/p/d26b3c/32.png) [@pete31](https://discourse.devontechnologies.com/u/pete31)
#### Post date: [February 27, 2022, 3:20am UTC](https://discourse.devontechnologies.com/t/rename-using-custom-data-for-human-being/69820/3 "2022-02-27T03:20:15Z")

</div>

> [@olivenoire](#):
>
> I simply want to use the “identifiant” to rename my file

This script renames based on Custom Meta Data.

Please try it with duplicates.

## Setup

- Open `Script Editor.app`
- Paste the script
- Replace `mdextags ` in line `set thisRecord_CustomMetaData_Value to mdextags of thisRecord_CustomMetaData` with `md` plus your Custom Meta Data identifier
- Save script to DEVONthink’s script menu folder  
`~/Library/Application Scripts/com.devon-technologies.think3/Menu/`

## Usage

- Select some records in the item list (or one of the other views).
- Run script via DEVONthink’s script menu.

```auto
-- Rename records based on Custom Meta Data

tell application id "DNtp"
	try
		set theRecords to selected records
		if theRecords = {} then error "Please select some records"
		
		repeat with thisRecord in theRecords
			set thisRecord_CustomMetaData to custom meta data of thisRecord
			try
				set thisRecord_CustomMetaData_Value to mdextags of thisRecord_CustomMetaData -- replace mdextags with "md" plus your identifier
				set name of thisRecord to thisRecord_CustomMetaData_Value
			end try
		end repeat
		
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink" message error_message as warning
		return
	end try
end tell

```

---

_[View the full topic](https://discourse.devontechnologies.com/t/rename-using-custom-data-for-human-being/69820)._
