Skip to Main Content

Brown University Scholarly Resources

Scripting and Automation

 

995 Cataloging/Original/Enrich/Batch

Alma's MDE can be a bit finnicky about script timing and sometimes this script will work flawlessly and other times it will ignore a key press and cause content to be inserted into an indicator. If this happens, just remove the mishap field and try again. Typically it will work flawlessly after a mishap.

Alternatively, you can remove all lines between the Chrome line and the initials line. This will remove the steps that create a new field and skip straight to inserting the subfields. In this case the user can create the 995 field on their own and when they go to enter the subfield content they can trigger the script.

For PC Users:

  1. Open a new text file in a notepad program (ie. notepad, notepad ++, etc)
  2. Copy and paste the following script into the notepad and follow comments (marked by ') to make changes as needed:

Dim objResult

Set objShell = WScript.CreateObject("WScript.Shell")
dim aDate

aDate = WScript.CreateObject("System.Text.StringBuilder").AppendFormat("{0:yy}{0:MM}{0:dd}", Now).ToString()

 

'Activates the browser. Change Chrome to Firefox as needed.
objShell.AppActivate("Chrome")


objResult = objShell.sendkeys("{F8}")
Wscript.Sleep (600)
objResult = objShell.sendkeys("995")
Wscript.Sleep (1000)
objResult = objShell.sendkeys("{TAB}{TAB}")
Wscript.Sleep (1000)

 

'Change Original to Catalog, Enrich, or Batch as needed. Change initials to your initials (ie. ah, jph, etc)
objResult = objShell.sendkeys("Original $$c initials $$d ")

 


Wscript.Sleep (600)
objResult = objShell.sendkeys (aDate)

 

  1. Save file to Desktop as [filename].vbs (ie. ahcat.vbs)
  2. Right click file and create a shortcut on the desktop.
  3. Right click shortcut and select properties
  4. Click the Shortcut key box and press your desired shortcut key. It is suggested using keys you never use such as the number pad on the right side of the keyboard.
  5. Save
  6. When editing a record in Metadata editor, press your shortcut key to automatically add a 995.

For MAC Users:

  1. Open Automator and select new file > Quick Action
  2. Under 'Workflow receives', set to 'no input' in 'any application'
  3. Under Actions, Select 'Run AppleScript'
  4. In the new box, erase all text and replace it with the following:
on run {input, parameters}
    tell application "Google Chrome"
        activate
        tell application "System Events" to key code 100
        delay 1
        tell application "System Events" to keystroke "995"
        delay 1
        tell application "System Events" to key code 48
        delay 2
        tell application "System Events" to key code 48
        delay 1
        set {year:y, month:m, day:d, time:t} to (current date)
        set mm to (m as number)
        if mm < 10 then set m to "0" & mm
        if d < 10 then set d to "0" & d
        set y to text 3 thru 4 of (y as string)
        set customDateTime to (y as text) & m & d
        tell application "System Events" to keystroke "Catalog $$c Initials $$d " & customDateTime
    end tell
    return input
end run
  1. Save Macro
  2. Under System Preferences > Security & Privacy > Privacy > Accessibility: Make sure to press the lock button to make changes, then add Finder, Automator, and Applescript to allowed applications.
  3. Under System Preferences > Keyboard > Shortcuts>Services: Double click the macro you saved earlier and select the keypad shortcut (e.g. Shift+Command+9)
  4. To Use this macro you will need to have Finder as the open window. To do so, just click on an empty space on your desktop, then press your shortcut keys. It will automatically select the browser and enter the new field in MDE.