Help with Finder's duplicate - set name

Hi,
I know this is probably a big ask but im having lots of trouble with this:


on themeDock()
	set _2 to path to resource "doxotheme.app" as string
	
	set tmpPath to (path to home folder as text) & "Library:"
	set themePath to tmpPath & "doxotheme.app:Contents:Resources:"
	--loading screen
	set visible of window "main" to false
	tell window "wait"
		set visible to true
		start progress indicator "loading"
	end tell
	--start the file moving
       
	tell application "Finder"
		--duplicate the doxotheme.app to a tmp location
		duplicate _2 to tmpPath with replacing
		-- i need help with the next steps please!
	end tell
	
	
end themeDock

(from the help comment in code)

there is a global variable named mainImage, it contains a path to an image :wink:

what i am trying to do is duplicate the image into the resources file of an application that is hidden in the library folder (see code)

The image must be called a certain name and replace any images with that same name

seems simple enough?
but I can’t figure out how I can do it :frowning:

if anyone can show I will be forever grateful to you and this forum!!
thanks sooo much if you can help :smiley:

Hi,

I recommend to use the shell for the duplicate job


on themeDock()
	set _2 to path to resource "doxotheme.app"
	set tmpPath to path to library folder from user domain -- result is an alias
	set themePath to (tmpPath as text) & "doxotheme.app:Contents:Resources:"
	--loading screen
	set visible of window "main" to false
	tell window "wait"
		set visible to true
		start progress indicator "loading"
	end tell
	--start the file moving
	
	do shell script "cp " & quoted form of POSIX path of _2 & " " & quoted form of POSIX path of tmpPath
	do shell script "cp " & quoted form of POSIX path of mainImage & " " & quoted form of POSIX path of themePath
end themeDock

I recommend full paths for do shell script instead of relying on the environment.

I recently posted this to the FaceSpan 5 mailing list because another user was failing to notice that the environment (PATH specifically) was different from what he expected it to be.

thanks -
@StefanK


do shell script "cp " & quoted form of POSIX path of _2 & " " & quoted form of POSIX path of tmpPath
   do shell script "cp " & quoted form of POSIX path of mainImage & " " & quoted form of POSIX path of themePath

isn’t that just moving the files - what about the renaming the image (and replacing)?
thanks so far :slight_smile:

cp

¢ copies the file with replacing (default setting)
¢ can rename the file foo.jpg to bar.jpg using the syntax

/bin/cp /path1/foo.jpg /path2/bar.jpg

Aah!
CP is treating the application it needs to copy as a directory!!

thanks if you can help!

do shell script "cp -pr " & quoted form of POSIX path of _2 & " " & quoted form of POSIX path of tmpPath