Duplicate Records

Summary: Copies the selected records.
Requires: EagleFiler
Install Location: ~/Library/Scripts/Applications/EagleFiler/
Last Modified: 2020-11-04


This script creates copies of the selected records. The copies have the same notes and tags, which makes it easy to create a bunch of documents with similar content and metadata.

Installation Instructions · Download in Compiled Format · Download in Text Format


tell application "EagleFiler"
set theSelection to selected records of window 1
tell library document 1
repeat with theTemplate in theSelection
set theFile to theTemplate's file
set thePath to POSIX path of theFile
set theName to do shell script "basename " & thePath's quoted form
set tempFolder to do shell script "mktemp -d -t 'EFDuplicateRecord'"
set tempPath to tempFolder & "/" & theName
do shell script "cp -Rp " & thePath's quoted form & " " & tempPath's quoted form
set tempFile to tempPath as POSIX file
set theContainer to theTemplate's container
set theTags to theTemplate's assigned tags
set theTagNames to {}
repeat with theTag in theTags
copy theTag's name to end of theTagNames
end repeat
set theNote to note text of theTemplate
import files {tempFile} tag names theTagNames note theNote container theContainer with allowing duplicates
end repeat
end tell
end tell