Sitemap | EndNote
Showing results for 
Search instead for 
Do you mean 
Reply
Highlighted
Visitor
Posts: 2
Registered: ‎11-13-2013
0 Kudos

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.

Highlighted
Mentor
Posts: 8,470
Registered: ‎04-10-2008
0 Kudos

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.  

(long time Endnote user)
Highlighted
Contributor
Posts: 31
Registered: ‎04-07-2008
0 Kudos

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

 

Highlighted
Visitor
Posts: 2
Registered: ‎11-13-2013
0 Kudos

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?

 

Highlighted
Contributor
Posts: 31
Registered: ‎04-07-2008
0 Kudos

Re: How can I change all PDF links (absolute and relative) to new absolute links in bulk?

Oh!  My bad, entirely.  I happen to work with almost entirely Mac users and just didn't stop to think that you might be on a Windows machine.  My apologies.  The answer is, unfortunately, "I don't know if there is an equivalent in Windows EndNote."

Highlighted
New User
Posts: 1
Registered: 3 weeks ago
0 Kudos

Re: How can I change all PDF links (absolute and relative) to new absolute links in bulk?

I am just posting this, if someone is interested in it...I recently had to change computers and the new computer required all my data to be in a specific folder that was different than my old computer's data folder.  Consequently, all my absolute links to pdf reference files did not work but I was able to fix it in bulk.

For the purpose of demonstration: My old computer's data file directory was C:\Olddata and my new computer's directry is C:\Newdata.

Open your EndNote (I have version X9) library that you want do fix. Select File>Export>Save as type: XML; uncheck Export Selected References; select a temporary location; Save the file.

Close the library in EndNote

Open the temporary location. Right-click on the exported .XML file and open with NotePad.

Replace> All> C:\Olddata with C:\Newdata

Save file (it will automatically saved as a .txt file)

Return to EndNote.

Create a new blank library by File>New>Give in name and a desired location

Select File>Import>File...> Select your import file (the .txt file); Import Option: EndNote generated XML; Import the file

The new library is filled with the references from the old library with updated absolute links.  All our reference fields are transfered.