DT3 Criar versão do record

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

-- 2020-01-29-17-36

tell application "DEVONthink 3"
  try
    set theSelection to the selection
    repeat with theRecord in theSelection
      if type of theRecord is not group then
        --set theLocation to location of theRecord
        
        
        set theLocation to "/Backup/" & my replace_chars(name of theRecord, "/", "_") & " Versions"
        set theGroup to create location theLocation
        
        set theDuplicate to duplicate record theRecord to theGroup
        set name of theDuplicate to (modification date of theRecord) as string
        
        set (exclude from classification of theDuplicate) to true
        -- set (exclude from search of theDuplicate) to true
        set (exclude from see also of theDuplicate) to true
        
        
        set thePrototype to "Backup"
        add custom meta data thePrototype for "Prototype" to theDuplicate
        set theIcon to "/Users/bernardovasconcelos/Dropbox/001 Megawiki/Icons/Prototype - Backup.png"
        set the thumbnail of theDuplicate to theIcon as string
        set the thumbnail of theGroup to theIcon as string
        
        set the tags of theDuplicate to thePrototype
        
        set locking of theDuplicate to true
        
        set theName to name of theRecord as text
        display notification "New version of " & theName & " successfully created"
        
      end if
    end repeat
  on error error_message number error_number
    if the error_number is not -128 then
      try
        display alert "DEVONthink Pro" message error_message as warning
      on error number error_number
        if error_number is -1708 then display dialog error_message buttons {"OK"} default button 1
      end try