Duplicate items into a folder created by the script

The script below creates a new folder with the current date and time as the folder name. In this same script how can I duplicate files into the new folder?The folder name will be unique every time the script is run so I can’t just type a path to the folder. Thanks.

set the_backup_source to alias "Powerbook:Users:dou:Documents:script tutorial:daily intake:"
set the_backup_destination to alias "Powerbook:Users:dou:Desktop:auto backup:"
set the_date to current date
set the_time to time of (current date)
set folder_name_prefix to the date string of the_date
set folder_name_suffix to the_time
tell application "Finder"
	make new folder at the_backup_destination with properties ¬
		{name:folder_name_prefix & "_" & folder_name_suffix}
	duplicate every item of the_backup_source to the_backup_destination with replacing
	set label index of the_backup_destination to 6
end tell

adiallo,

Try using this line:

set theFolder to make new folder at the_backup_destination with properties ¬
       {name:folder_name_prefix & "_" & folder_name_suffix}

You can then use the variable “theFolder” to reference your newly created folder.

PreTech

PreTech,
THat’s just what I was looking for. Thanks for showing me how to set the variable.

Spoke too soon…

set theFolder to make new folder at the_backup_destination with properties ¬
	{name:folder_name_prefix & "_" & folder_name_suffix}

gives the error: “can’t make current application into type location reference”
So how do I set a variable for the folder referenced below?

make new folder at the_backup_destination with properties ¬
		{name:folder_name_prefix & "_" & folder_name_suffix}

Thanks

Hi,

Here’s an example:

set dp to (path to desktop as string)
set s to (dp & “f1:”) as alias
set bd to (dp & “f2:”) as alias
set d to (current date)
set t to time of d
set p to the date string of d
set the_name to (p & “_” & t)
tell application “Finder”
set r to (make new folder at bd with properties {name:the_name})
duplicate every item of s to r with replacing
end tell

Maybe you forgot tthe tell block?

gl,

Thank kel,
With your example I was able to find my mistake. The variable works now.