Adding Tags in Document from Filename

Hi All,

I’m trying to extract a 9 digit number from a filename and then use that number to create a metadata for "Tags" in Word and PDF files. The number is unique for each file. If it matters, the 9 digit number is followed by an _ or a space or text, but I only want the 9 digit number as a tag.

If anyone is aware of a script or command that can do this, I'd really appreciate it!

Also, to perhaps skip the above: the ultimate reason for doing this it so move the above files to their respective folders which consists of that unique 9 digit number. The reason for adding the tags is because I think I found a way for Hazel (Mac app) to do it if tags match the folder name.

Is there a way for Directory Opus to do this?

Thanks!

It might help if you gave example filenames. You can use 123456789 as the number and then whatever for the rest of the filenames, just keep the parts of the filename distinct and accurate (space, punctuation, etc.).

Some examples (let's pretend part of the name includes a person's name...you could use a pretend name like James Kirk):

123456789_Kirk, James.pdf

Or:

Kirk-James 123456789.pdf

Or something like that to show your potential helpers how your files are named.

Also, I can affirmatively say that this is possible, including moving the file into your 9-digit-name folders.

May I suggest linking your forum account? The developers are more likely to assist if they see that you've linked your account.

Manipulating tags will require a script, but if you simply want to move files based on their names the Advanced Rename can handle this.

Try this as a start:

Mode: RegEx
Old name: (.*)(\d{9})(.*)
New name: \2\\\0
Ignore extension: checked

It will move the selected files into subfolders named after the nine digit number (if there is any).

Thank you so much!
The files did move but not exactly how I wanted them to though.

I already have existing folders which include the unique number, plus text, but Dopus created new folders with only the unique number as a folder name, and moved the files into that folder.

Also, while testing it made the folders in the same folder as the Word/PDF documents, however in the practical situation I need this for, the Word/PDF files and the folders to move them into are in different locations.

To answer DesertDwarf's questions, the files and folders are a combination of 123456789_Firstname_Lastname.docx. Instead of _'s there may be spaces, or commas or no spaces at all. What will be certain though, is that the name is begins with 9 numbers.

Thank you both!