Change default download folder in Safari

Hi Guys,
I am trying to change default download folder in Safari using defaults command,but it not takes effect when i running it via shell script.

Could you please help me - i need it by any way.
I stuck for choosing the folder using UI elements in apple script also.

Many thanks,
Lilya

Hello KniazidisR

I’m puzzled.
There is no folder com.apple.Safari in the folder Containers of my Home folder.

set path2plist to (path to home folder as text) & "Library:Containers:"
tell application "Finder"
	exists folder path2plist
	log result
end tell

set path2plist to path2plist & "com.apple.Safari:"

tell application "Finder"
	exists folder path2plist
	log result
end tell

The events log is :

tell current application
	path to home folder as text
		--> "SSD 500:Users:**********:"
end tell
tell application "Finder"
	exists folder "SSD 500:Users:**********:Library:Containers:"
		--> true
	(*true*)
	exists folder "SSD 500:Users:**********:Library:Containers:com.apple.Safari:"
		--> false
	(*false*)
end tell

The only folder with this name is :
“SSD 500:Users:**********:Library:WebKit:com.apple.Safari:”

In the Containers folder, the unique folder related to Safari is :
“SSD 500:Users:**********:Library:Containers:com.apple.Safari.CacheDeleteExtension:”

The default Downloads folder is defined in the entry : DownloadsPath
in the file :
“SSD 500:Users:**********:Library:Preferences:com.apple.Safari.plist”

In the same file, the entry NSNavLastRootDirectory points to the Desktop.

Auxiliary comment, in the UI code there is no need for:

set downloadsFolder to POSIX path of (path to desktop folder)
-- copy the download folder path to the clipboard
set the clipboard to downloadsFolder as text

because downloadsFolder, like every POSIX path IS a string

set downloadsFolder to POSIX path of (path to desktop folder)
-- copy the download folder path to the clipboard
set the clipboard to downloadsFolder

is sufficient.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 15 juin 2019 17:39:07

No, it’s not damaged.
I have exactly the same items on three different volumes used separately with different versions of the System.

Maybe these items appeared with Mojave which I can’t install.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 15 juin 2019 22:34:17