You can do it with AppleScript. I’ve pasted below a script I wrote that you can use as a starting place. Obviously, it will take some modificaiton. Also, I wrote it early in my AppleScript learning, so it is pretty ugly in terms of how I coded it. I hope it is helpful as a start.
-- Verion of 121026
-- Renames the attached full document of the selected EndNote record to the form "Jones_1996_114", where 114 was the record number
-- It is horribly ugly and specific to the author, but should be easily adjustable for others.
tell application "EndNote X7"
activate
set myFile to first document
set myRecord to retrieve "selected" records in myFile
repeat with myRecordID in myRecord
--This part added to fix imported files that aren't in the right directory
set junk to field "File Attachments" of record myRecordID
if (offset of "-pdf" in junk) > 0 then -- does "Internal-pdf" show up in file attachment?
--if (offset of "-pdf" in field "File Attachments" of record myRecordID) > 0 then -- does "Internal-pdf" show up in file attachment?
set oldPDF to field "File Attachments" of record myRecordID
tell me
set oldPDF2 to replace_chars(oldPDF, "%20", " ")
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set currName to last text item of oldPDF2
end tell
set currPath to field "File Attachments" of record myRecordID
set AppleScript's text item delimiters to "//"
set currPath to text item 2 of currPath
set AppleScript's text item delimiters to "/"
set currPath to text item 1 of currPath
set newFA to "/Users/ghoetker/Dropbox/PDF_storage/" & currName as text
set field "File Attachments" of record myRecordID to newFA -- So the record will point at the renamed attachment
tell application "Finder" -- duplicate into the right folder
set destFolder to "Users:ghoetker:Dropbox:PDF_storage" as alias
set folPath to "Users:ghoetker:Documents:GPH_Endnote_2012.enlp:GPH_Endnote_2012.Data:PDF:" & currPath as alias
set moveMe to file currName of folPath
try -- If successfully moved, remove the original and its folder
duplicate moveMe to destFolder
on error
display dialog "Couldn't find original file"
return
end try
-- delete moveMe
delete folPath
end tell
end if
--Figure out the current name of the attachment
set myPDF to field "File Attachments" of record myRecordID
tell me
set myPDF2 to replace_chars(myPDF, "%20", " ")
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set currentName to last text item of myPDF2 --We need this to know what to rename
end tell
--Figure out the pieces of the attachment's new name
set theAuthor to first word of (field "Author" of record myRecordID)
set theYear to field "Year" of record myRecordID
tell me -- Can't get this directly from EndNote like author, year, etc
set AppleScript's text item delimiters to {"\""}
set theRecNo to fourth text item of myRecordID
end tell
tell me
set newFileName to theAuthor & "-" & theYear & "-" & theRecNo & ".pdf" as text
end tell
--The next section points the record at the soon to be newly named attachment
tell me
set newFileName to theAuthor & "-" & theYear & "-" & theRecNo & ".pdf" as text
end tell
set newFileAttach to "/Users/ghoetker/Dropbox/PDF_storage/" & newFileName as text
set newFileAttach2 to (the POSIX path of newFileAttach)
set field "File Attachments" of record myRecordID to newFileAttach -- So the record will point at the renamed attachment
try
tell application "Finder" -- Rename the actual file
set folderPath to (path to home folder as text) & "Dropbox:PDF_storage" as alias
set name of file currentName of folderPath to newFileName
end tell
on error error_message number error_number
if error_number is -10006 then
--display dialog "File or folder not there"
--quit me
else if error_number is -15267 then
display dialog "File already exists"
quit me
else
display dialog "Other error"
quit me
end if
end try
end repeat
end tell
display dialog "All done"
--tell application "Finder" -- Rename the actual file
-- set folderPath to (path to home folder as text) & "Dropbox:PDF_storage" as alias
-- set name of file currentName of folderPath to newFileName
--end tell
--A necessary function
on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars