How can I change all PDF links (absolute and relative) to new absolute links in bulk? (Thomson Reuters Community Subscription Update)

Search email archive for  

How can I change all PDF links (absolute and relative) to new absolute links in bulk? (Thomson Reuters Community Subscription Update)
Author: Community Mailer    Posted: Wed, 13 Nov 2013 02:17:28 -0800
Subject: How can I change all PDF links (absolute and relative) to new absolute links in bulk?

I have an Endnote library (Library.enl) with around 1000 entries. Some enties have absolute PDF links, such as C:\OldPath\File1.pdf, C:\OldPath\File15.pdf, and some have relative PDF links, such as FIle23.pdf, File158.pdf. How can I change all PDF links (absolute and relative) to new absolute links in bulk, such as D:\NewPath\File1.pdf, D:\NewPath\File15.pdf, D:\NewPath\File23.pdf, D:\NewPath\File159.pdf? I am happy to edit the Library.enl file manually, please help me how. Thank you.

Re: How can I change all PDF links (absolute and relative) to new absolute links in bulk? (Thomson Reuters Community Subscription Update)
Author: Community Mailer    Posted: Wed, 13 Nov 2013 07:11:56 -0800
Subject: Re: How can I change all PDF links (absolute and relative) to new absolute links in bulk?

I believe you can only change absolute to relative quickly and easily.  There is no automated way to move relative saved PDF to a new location in bulk within endnote and retain a link.    There is a thread from a few years ago discussion some trials, but I don't think they came to a solution.  You can look at that thread here.  

Re: How can I change all PDF links (absolute and relative) to new absolute links in bulk? (Thomson Reuters Community Subscription Update)
Author: Community Mailer    Posted: Wed, 13 Nov 2013 10:27:01 -0800
Subject: Re: How can I change all PDF links (absolute and relative) to new absolute links in bulk?

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  

Re: How can I change all PDF links (absolute and relative) to new absolute links in bulk? (Thomson Reuters Community Subscription Update)
Author: Community Mailer    Posted: Thu, 14 Nov 2013 05:16:43 -0800
Subject: Re: How can I change all PDF links (absolute and relative) to new absolute links in bulk?

Thank you for the reply. How could I run AppleScript on Windows 8 machine? Is there any similar script for Windows?  

Previous by date: Re: endnote x7 + word 2011 + osx mavericks (10.9) = working? (Thomson Reuters Community Subscription Update), Community Mailer
Next by date: Re: How can I change all PDF links (absolute and relative) to new absolute links in bulk? (Thomson Reuters Community Subscription Update), Community Mailer
Previous thread: with the winners meeting in the (Thomson Reuters Community Subscription Update), Community Mailer
Next thread: How can I change all PDF links (absolute and relative) to new absolute links in bulk? (Thomson Reuters Community Subscription Update), Community Mailer

For the time being we are unable to offer the following product ranges although we are currently working hard to increase the number of products we can offer in the future. Please contact us to talk about alternative products that we may be able to offer you.