Export Web Page to Nominated Folder

Used to be able to export Web pages to a Folder nominated in the routine but it no longer works, it does not seem to work manually either at least using the command to get to the folder in finder " command shift g".

The following opens sheet from which the name can be set and in theory change the folder destination. The routine does that but then saves the file to the last folder used. The last time I used this was before Catalina so maybe that’s the issue. Appreciate any suggestions.

set FolderName to "Macintosh HD:Users:petermitchell:Dropbox:Quantum:/"
tell application "Safari"
	activate
	tell application "System Events"
		tell process "Safari"
			click menu 1 of menu bar item "File" of menu bar 1
			delay 2
			select menu item "Export as PDF…" of menu 1 of menu bar item "File" of menu bar 1
			click menu item "Export as PDF…" of menu 1 of menu bar item "File" of menu bar 1
			set y to 1
			repeat until exists combo box 1 of sheet 1 of sheet 1 of window 1
				try
					keystroke "g" using {command down, shift down}
					delay 2
					exit repeat
				end try
				set y to y + 1
				if y = 20 then exit repeat --Added to make sure not an infinite loop
			end repeat
			repeat 10 times
				try
					set value of combo box 1 of sheet 1 of sheet 1 of window 1 to FolderName
					click button 1 of sheet 1 of sheet 1 of window 1 --to accept folder
					exit repeat
				end try
				delay 0.5
			end repeat
			set value of text field 1 of sheet 1 of window 1 to "test.pdf"
		end tell
	end tell
end tell

Hi,

  1. Your folder path should be in the form of Posix path instead of HFS path. Your script still works on the Catalina.

“/Users/petermitchell/Dropbox/Quantum/”

  1. Go System Preferences–>Keyboard–>Shortcuts–>App Shortcuts. Check if shortcut Shift+Command+“g” is activated for “Go to folder” command. If not, set its checkbox.

You can check THIS shortcut pressing “GO” menu of menu bar of Finder as well. See if the shortcut is present with “Go to folder” menu item when menu of “GO” opens.

Hi

Once again my thanks , you were of course correct , I had to add the short cut command+shift+g to keyboard preferences .

Also changed the path to the Posix version.

Interesting about my query re the change to Catalina when I checked carefully my old version including the routine my path command was a little different but in the Posix form, “set SaveFolderPath to “~/dropbox/Quantum/AccountDataFromOperators/EnergyLink/” & SaveState & “.pdf”” . The routine was a little different than what I am now trying to achieve and it did not work obviously because of the required addition to keyboard preferences.

So obviously the key was the missing short cut & my sloppy programming (HFS).

Thanks again. Peter