Hi,
I am looking for a script and unfortunately I am not able to create this myself to (auto-)rename files as soon as they arrive in the finder inbox folder with the format YYYY_MM_DD_HH:MM_TITLE or YYYY_MM_DD_HH:MM_SUBJECT.
I somehow changed the rename to creation date script and the result is 2019_04_09 22:13 - for whatever reason it is not really doing what I want as well as I have no idea how to add the Subject or the title of the file name.
Can anybody give me a kickstart please. I hope this is also helpful then for others.
Thanks and regards
- Items won’t auto-rename when they arrive in your Global Inbox.
- Using punctuation outside hyphens, underscores, and spaces in a filename is generally not recommended.
How are you expecting to get the title or subject? They are not attributes of most file types. Are you thinking of entering them by hand in a display dialog
? What kind of files are you referring to?
If you’re referring to the Inbox folder from DEVONthink in the Finder’s sidebar is the Global Inbox.
A PDF title would be part of the metadata for the file.
This is a simple example working on a selected PDF in DEVONthink…
tell application id "DNtp"
repeat with thisRecord in (selection as list)
set md to (meta data of thisRecord)
set theTitle to kMDItemTitle of md
end repeat
end tell
1 Like
Thanks a lot @BLUEFROG - but as far as I understand the code the date is not included? I have to apologise like most of non-developers I am able to adopt a script but not to combine both - date and tile - to one.
@BLUEFROG,
What kind of character do you suggest for using in filenames, especially working good with Devonthink Express?
Generally speaking, the safest option is just hyphens, underscores, dots (periods, though a single dot before a file extension is preferred), and spaces.
Note, this is a strictly safe method, so there is some flexibility but I generally advocate a safer route.
We actually blogged some about filenaming:
You’ll notice there’s only hyphens and spaces, and all the information is well understood without using excess punctuation.
Also notice what happened in the screen capture shown…
The operating system converted the colon to a hyphen because you can’t put a colon in a filename. So there is a technical discrepancy between the title and filename. This may be acceptable in a specific situation… or it may not.
This is assuming the file is named with the datestamp as shown in your screencapture… Running this on a PDF selected in DEVONthink will change the name of the file. If no title is detected, it will display a dialog to enter one.
tell application id "DNtp"
repeat with thisRecord in (selection as list)
if type of thisRecord is PDF document then
set recName to name of thisRecord
set md to (meta data of thisRecord)
try
set theTitle to kMDItemTitle of md
on error
set theTitle to text returned of (display dialog "Enter a title for use in the file's name" default answer "")
end try
set name of thisRecord to (recName & "_" & theTitle)
end if
end repeat
end tell
@BLUEFROG Thanks for your help. I have to apologise that I found a solution with Hazel which is much more convenient for me as I am not being able to script.