Forum moved here!

Home / How to automate opening a PDF from an external drive when the drive letter varies?

Josefien

SumatraPDF-3.2-32 is installed on a USB stick and works fine, I can open a PDF document in landscape, one full page at the time.
But… The drive letter of the inserted stick varies due to use on different computers (used on universities on a video wall/screen for educational purpose)
So the file sumatrapdfcache is often pointing to the wrong drive letter.
I think I did read evertything about additional command-line options and changing the *.ini (settings) file.

I want to start SumatraPDF-3.2-32, and open automaticly at start up a file named “lecture-sept.pdf”. Manually selecting next page.
The drive letter -as mentioned- varies. Sumatra, settings file, sumatrapdfcache, and the PDF are in te same map on the stick.
-presentation : display in presentation view?
-fullscreen : display in full screen view?
-view “single page” or “continuous single page” (one full page at the time)?

I can write batch (cmd) files, no problem.
Can some pls help me out with the necessary settings? Thanks beforehand.

GitHubRulesOK

\sumatrapdfcache should not be an issue itself as it should be “relative” in the same folder as the portable.exe (avoid any “portable app” variations that may fiddle with the data files, some are good but some are not).

[Update]
In most recent Pre-release versions if the file was on a “removable” drive (however some modern USBs are set as “fixed letter drives”) SumatraPDF will tag the drive entry as variable with ?:\ and try different drives. however that too can cause problems Pre-release version 32-bit. Memorized files are not opened from the start page after restarting the program · Issue #2219 · sumatrapdfreader/sumatrapdf · GitHub

So for the above case, there should be no problem dropping a usb.pdf onto the usb sumatrapdf.exe with -fullscreen in a shortcut and the solution below is only needed for multiple tab users.

For one file all you need is a bat file or shortcut with

"%~d0\Apps folder\SumatraPDF\SumatraPDF.exe" -fullscreen "%1"

that allows you to drop a file onto it
or to simply double click the bat file change that to

    "%~d0\Apps folder\SumatraPDF\SumatraPDF.exe" -fullscreen "%~d0\Data files\lecture-sept.pdf"

The main problem could be in the history of more than one file that you opened last time on the F drive but now are in the same folder on G

The simplest solution in that case is to replace in SumatraPDF-settings.txt any previous F:\ with G:\

There may be clever ways to do that in raw powershell vba wscript etc.HOWEVER as there is a risk you may not find that on ALL other machines or be restricted then I suggest its simplest to use just .batch .cmds

FilePath = %~d0[etcetera]

If the drive is the same as %lasttime% it wont matter so adding that all up in your cmd

call %~d0\lastdrive.bat
"%~d0\Apps\File Tools\fart\fart199c\fart32.exe" -i "%~d0\Apps\SumatraPDF\SumatraPDF-settings.txt" "FilePath = %lastdrive%" "FilePath = %~d0"
echo set lastdrive=%~d0> %~d0\lastdrive.bat
"%~d0\Apps\SumatraPDF\SumatraPDF.exe" -fullscreen "%1"
pause

and that last %1 allows you to drag a different first file (lecture-sept.pdf if you wish) onto the cmd to start the session off or replace the "%1" with

"%~d0\Apps\lecture-sept.pdf"

of course you can remove \ edit those folders and subfolders as you wish

Josefien

Thanks! It works fine.