Loading ...
Sorry, an error occurred while loading the content.

Clip using command line

Expand Messages
  • Adrian/ Rosemary Worsfold
    I found making the clip below interesting - use of the ^!Shell and command line. First of all I discovered the one using WordWeb (thesaurus) and sometimes text
    Message 1 of 1 , Mar 23, 2005
    • 0 Attachment
      I found making the clip below interesting - use of the ^!Shell and command line.

      First of all I discovered the one using WordWeb (thesaurus) and sometimes text was typed
      into it and sometimes it went in NoteTab. Basically, the first time it was used it did not work,
      and then it did. Something about the delay, I thought, but trials turned out to show not. My
      method to get something to work is struggle, and I succeeded when I produced two of them,
      and there is even a loop once it runs to remove one.

      Now in the clip below I progressed to using a command line program, the freeware
      pdftotxt.exe, where it seems to me NoteTab is suited to run it. I had had a clip that simply
      opened folders and copied text to the clipboard to allow easier manual command line
      operation, but having learnt something I wanted to make the clip as automatic as possible.

      I had the same problem again. Sometimes the pdftotxt did what it was expected to do, but
      more often than not it did not. In the process (slightly desperately) I put back in lines that
      allowed manual operation (EXTRA below). This indeed showed the program did work, but it
      was not working from NoteTab, despite delays and waits and focus. The solution is similar to
      WordWeb, I discovered through some thought and the struggle. It is to force it twice. It now
      seems to work every time. This is most odd. The clip follows, and remember those long lines
      if you download pdftotxt.exe plus the positions of files and programs should change to suit
      your own computer.

      H="PDF text insert"

      ^!Close ALL
      ^!Save AS C:\My Documents\temp.tmp

      ^!SetWizardLabel Find PDF file to extract text from
      ^!Set %Folder%=^?{(T=D)&Browse: Confirm OK or press the button to navigate=^$GetValue

      ^!StatusShow Finding files
      ^!SetScreenUpdate Off

      ^!Set %Type%=*.pdf
      ^!Set %Sort%=Name

      ^!Close DISCARD
      ^!DestroyDoc C:\My Documents\temp.tmp

      ^!Set %FullPath%=^$GetFileFirst(^%Folder%;"^%Type%";^%Sort%)$
      ; Checks to see if files are found by search criteria
      ^!IfTrue ^$IsEmpty("^%FullPath%")$ NONE

      ^!IfTrue ^$IsEmpty(^%FullPath%)$ DOARRAY
      ^!Append %Files%=^%FullPath%|
      ^!Set %FullPath%=^$GetFileNext$
      ^!Goto LOOP1


      ^!SetArray %EditList%=^?{(T=L;H=10)Is it here? Click on one=^%Files%}
      ^!Set %Count%=^%EditList0%
      ^!Set %Index%=0

      ;When it chooses a file the index position forces it out of the loop
      ^!Set %FilePathFull%=^%EditList^%Index%%
      ^!Inc %Index%
      ^!If ^%Index% > ^%Count% PROCEED
      ^!GoTo LOOP2


      ^!Set %GoFile%=^$GetShort(^%FilePathFull%)$
      ^!CopyFile ^%GoFile% c:\progra~1\smallu~1\pdftot~1\fred.pdf
      ^!StatusShow File copied for manipulation
      ^!Delay 20
      ^!StatusShow Text file making

      ^!Shell "c:\progra~1\smallu~1\pdftot~1\pdftot~1.exe" fred.pdf fred.txt
      ^!ShellWait "c:\progra~1\smallu~1\pdftot~1\pdftot~1.exe" fred.pdf fred.txt
      ^!Delay 10

      ^!Open c:\progra~1\smallu~1\pdftot~1\fred.txt
      ^!IfError EXTRA

      ^!StatusShow Processing text
      ^!Keyboard CTRL+HOME
      ^!Replace ".^P" >> ".^P^P" [WAS]
      ^!Keyboard CTRL+HOME
      ^!Replace ". ^P" >> ". ^P^P" [WAS]
      ^!Keyboard CTRL+A
      ^!Toolbar Join Lines
      ^!StatusShow Processing text further

      ^!Keyboard CTRL+HOME
      ^!Replace "^P^P^P" >> "^P^P" [WAS]
      ^!IfError SPACEDOWN
      ^!GoTo REPLACER1

      ^!Skip Cut spaces down (a long process)?
      ^!GoTo FINAL
      ^!StatusShow Processing text further still

      ^!Keyboard CTRL+HOME
      ^!Replace " " >> " " [WAS]
      ^!IfError FINAL
      ^!GoTo REPLACER2

      ^!Continue Cannot get at the text - OK for a different method
      ^!SetClipboard fred.pdf fred.txt
      ^!shell c:\progra~1\smallu~1\pdftot~1\
      ^!Info [L]At the folder (taskbar below) right click on pdftotxt.exe and Send to Command Line
      and CTRL+V at its end
      ^!GoTo MAKE

      ^!StatusShow None in this folder
      ^!Delay 20
      ^!GoTo TOP

      ^!Save AS C:\My Documents\Adrian\Preparations\Temporary.txt
      ^!RecycleFile C:\Program Files\Small Utilities\pdftotext\fred.txt
      ^!RecycleFile C:\Program Files\Small Utilities\pdftotext\fred.pdf
      ^!SetScreenUpdate On
      ^!Prompt Save to a permanent filename if inserting more .PDF text.

      Adrian Worsfold

    Your message has been successfully submitted and would be delivered to recipients shortly.