Yet again...renaming a copied folder

Shouldent be too complecated: I copy a folder and want to rename it immediately.


set DBPROP to "Gentfamdisc:Users:Tim:Saved:Applescript scripts:Extra items(pics, sounds...ect):desktop backgrounds PRO:"
set DBM to "desktop backgrounds"

tell application "Finder"
duplicate (alias DBPROP) to dsktopP
		set the name of the selection to DBM
end tell

This dosent work. Why?

this is the “Event log”

tell application "Finder"
	activate
	move alias "Gentfamdisc:Users:Tim:Desktop:desktop backgrounds:" to trash
		folder "desktop backgrounds" of trash
	empty
		folder "desktop backgrounds O" of folder "Desktop" of folder "Tim" of folder "Users" of startup disk
	set name of selection to "desktop backgrounds"
		"Finder got an error: Can't set name of selection to \"desktop backgrounds\"."

Hi,

selection is a list of items which are selected in the frontmost finder window,
not the destination of the copied file/folder. This is the problem.

You can do it like this (assuming that the variable dsktopP is an alias of a folder):


set DBPROP to "Gentfamdisc:Users:Tim:Saved:Applescript scripts:Extra items(pics, sounds...ect):desktop backgrounds PRO:" as alias
set DBPROPname to name of (info for DBPROP)
set DBM to "desktop backgrounds"

tell application "Finder"
	duplicate DBPROP to dsktopP
	set name of alias ((dsktopP as string) & DBPROPname) to DBM
end tell