Hi,
Apparently, what I would like to seek help about is quite similar to the
issue raised here:
https://sourceforge.net/p/skim-app/mailman/message/37743641/

Specifically, what I need to do is the following:
If I have a lot of pdf files to read, here is what I usually do;
I convert them both to text-based pdfs and epubs, the same OCR app and then
send the epub file to Kindle using amazon's dedicated app.

... Then comes reading / highlighting on the Kindle and transferring the
"My Clippings" file in the kindle to the computer. Using a website I can
get transfer the highlights for only one book to, say, a text file.

Now, what would be incredibly useful is if after opening the pdf file on
Skim, I could have an applescript search for each highlight on the text
file in the pdf on skim and highlight it...

Further, if for one single highlight the script cannot find it (probably
because, it's too long) the script can reduce the number of the words to
look for and then add the highlight once it finds a match.

(e.g. a single highlight on Kindle:
"All men are mortal, Socrates is a man, therefore Socrates is mortal. "

When the script doesn't find a match for the whole sentence, it will search
for a phrase with a reduced number of words, say:

"All men are mortal, Socrates is a man,"

if still no match, reduce 4 words again:
Hi,
Apparently, what I would like to seek help about is quite similar to the
issue raised here:
https://sourceforge.net/p/skim-app/mailman/message/37743641/

Specifically, what I need to do is the following:
If I have a lot of pdf files to read, here is what I usually do;
I convert them both to text-based pdfs and epubs, the same OCR app and then
send the epub file to Kindle using amazon's dedicated app.

... Then comes reading / highlighting on the Kindle and transferring the
"My Clippings" file in the kindle to the computer. Using a website I can
get the highlights for only one book...

Now, what would be incredibly useful is if I after opening the pdf files on
Skim, I could then get the highlights for the single book on a text file
and have an applescript search for each highlight on the text file in the
pdf on skim and highlight it...

Further, if for one single highlight the script cannot find it (probably
because, it's too long) the script can reduce the number of the words to
look for and then add the highlight once it finds a match.

(e.g. a single highlight on Kindle:
"All men are mortal, Socrates is a man, therefore Socrates is mortal. "

When the script doesn't find a match for the whole sentence, it will search
for a phrase with a reduced number of words, say:

"All men are mortal, Socrates is a man,"

if still no match, delete the last 4 words from the search phrase again etc

"All men are mortal,"
But stop there, don't search for less than, say, e.g 4  words


Once it finds the phrase, the script will have skim highlight it.

And then will do the same for the second highlight from the Kindle/
ereader/ any textfile separated by "paragraphs" etc.


What do you think? Any chance for that? I was hoping that would be possible
nowadays and asked, of course, what else, ChatGPT
 Below is its reply: --well, it doesn't work..

Many thanks everyone!
-- Specify the paths to your text file and PDF file
set textFilePath to "/path/to/your/textfile.txt"
set pdfFilePath to "/path/to/your/pdfdocument.pdf"

-- Read lines from the text file
set linesToSearch to paragraphs of (read file textFilePath)

-- Iterate through each line and search for it in the PDF using Skim Reader
repeat with currentLine in linesToSearch
    set searchString to currentLine

    -- Use a shell command to search for the text in the PDF
    set searchCommand to "grep -n " & quoted form of searchString & " " &
quoted form of pdfFilePath
    set searchResult to do shell script searchCommand

    -- Extract the line number from the search result
    set lineNumber to first word of searchResult

    -- Use SkimNotes command-line tool to add annotation to the PDF
    set skimCommand to "skimnotes add -page " & lineNumber & " " & quoted
form of pdfFilePath
    do shell script skimCommand
end repeat

----
_______________________________________________
Skim-app-users mailing list
Skim-app-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-users

Reply via email to