insert creation date in the name of a file

No problem. :smiley:

I don’t see the “Rename to creation date” script. Is this no longer present in DEVONthink 3? I am looking for a script to rename files to date/time: YYYYMMDDHHMM

I attempted to modify ‘Prefix with creation date.scpt.zip’ linked above, but was not sure how to get at time (HHMM).

By the way - both batch processing and smart rules can perform renaming too (although in this case additional placeholders for hour and minute would be necessary as the time placeholder uses HH:MM).

But beta 3 will include the necessary placeholders :slight_smile:

2 Likes

Thanks for the reply! Batch Process... with placeholders gets me very close. Just need placeholders for Creation Hour and Creation Minute.

What’s the grammar to, e.g. add specific parts of the creation date to the record’s name?
The otherwise readworthy documentation leaves out the fineprint here.

Control-click > Insert Placeholder > …

Leading to a Batch Process of as an example…

I will think about ways to make this more clear.

1 Like

Very nice, thank you. Looks great.

You’re welcome. Cheers!

Hi all,

Is there any way to do the following:

  1. limit the year placeholder to 2 characters? So instead of 2019 -> 19
  2. how can I access the second that a file was created? I’ve tried %recordCreationSecond% but that doesn’t seem to work

I’d like to batch rename files in the following format yyMMddHHMMss without any delimiters.

Thanks in advance!

Welcome @sunnySloth

Neither of these options are possible via placeholders, only scripting.
Note: Many date renaming scripts have been posted on the forums over the years.

Here is one approach with a teaching edition AppleScript example…

tell application id "DNtp"
	repeat with thisRecord in (selection as list)
		set recordName to (name of thisRecord)
		set creationDate to (creation date of thisRecord)
		
		set thisYear to year of creationDate as string
		set thisMonth to month of creationDate as integer -- As string produces the name of the month.
		set thisDay to day of creationDate as string
		set thisHour to hours of creationDate
		set thisMinute to minutes of creationDate
		set thisSecond to seconds of creationDate
		
		set thisYear to (characters 3 thru 4 of thisYear) as string
		
		set titleDateString to (thisYear & thisMonth & thisDay & thisHour & thisMinute & thisSecond & "_")
		set name of thisRecord to titleDateString & recordName
	end repeat
end tell

From Script Editor, save this script in ~/Library/Application Scripts/com.devon-technologies.think3/Menus and you can use it on selected files from DEVONthink’s Script menu.

Hi Bluefrog! Thanks a mil for your help and the above script! It’s a huge help!

1 Like

You’re welcome :slight_smile:

Here you go. (Note: I’m actually going to completely rewrite it at some point but it should work).

Prefix with creation date.scpt.zip (4.31 KB)

Could you please share this script again, the current on is not working (unable to download without an error: This XML file does not appear to have any style information associated with it. ). Thank you :grin:

That’s old (and I’d have to track it down to reupload it).

In DEVONthink 3 you can use Tools > Batch Process to do the same operation.

That’s very helpful! Thank you @BLUEFROG

Is there a way I can define/create a placeholder to include all the individual ones I inserted? I know I can customise my meta in Preferences > Data but I couldn’t see a way to build a YYYYMMDDHHMMSS holder?

No you can’t create your own placeholder, not in the context we’re discussing.
What you’re showing here is the way you’d do it.

PS: You were just trying to script removing this date string from filenames. Are you trying to put it back on the files that were processed in the script with the incorrect RegEx?

Only for those that were changed by the first RegEx and left with the last word in the filename :wink:

Since this is a one-off, you could copy the placeholders in the Batch Process sheet, just in case, and just process what you need.