Overriding multiple files how to avoid multiple password pop ups?

I’m overriding multiple files that need admin password permission confirmation. Finder handles that and pops up a native dialog to confirm override with password but It’s doing this separately for each file in the loop. Is there any way to avoid this and have this confirmed in a single password entry pop up?

Code Block
tell application “Finder”
set filenames to {“file1.png”, “file2.png”, “file3.png”}
repeat with filename in filenames
try
set sourcefilepath to (PATH_ICONS) & filename
duplicate sourcefilepath to PATH with replacing
on error the errorMessage
display dialog errorMessage & "Could not override file " & FILE_TO_REPLACE
end try
end repeat
end tell

You may try:

set qpDest to quoted form of POSIX path of _PATH -- _PATH is not defined and PATH is not a valid name

set filenames to {"file1.png", "file2.png", "file3.png"}

repeat with filename in filenames
	try
		set qpSourcePath to quoted form of POSIX path of (PATH_ICONS & filename) -- PATH_ICONS is not defined
		do shell script "cp " & qpSourcePath & space & qpDest with administrator privileges
	on error the errorMessage
		display dialog errorMessage & "Could not override file " & FILE_TO_REPLACE -- FILE_TO_REPLACE is not defined
	end try
end repeat

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) samedi 4 juillet 2020 11:08:16

Thanks @Yvan This does the job and only asks once for the password. Also worth noting that this will not require another password entry even if another shell script is run outside of this loop, which is great and user friendly.