reference after duplication

Hello,
I want to create a script to duplicate a folder and then apply changes to the duplicated folder. I don’t know how to reference the duplicated folder. Here is my script:

if folder of the item_info is true then
tell application "Finder"
duplicate these_items to images_path
set dupli_folder to the result
set the name of dupli_folder to albumID
--process_folder(dupli_folder) --THIS PART DOES NOT WORK
else
display dialog "This script works only with folders."
end if

Hi CedAlex,
Add ‘as alias’ to this line:
set dupli_folder to the result as alias
What’s happening is that you’re changing the name of the duplicated folder, so, when it uses the old reference there is nothing there by that name. Using as alias will reflect changes to the name. After this line:
set the name of dupli_folder to albumID
try adding this:
display dialog (dupli_folder as string)
with and without the ‘as alias’. You’ll see that the path name will change with aliai.
gl, Kel.

It’s not clear from your variable names exactly what it is your script is duplicating to where. The variable ‘images_path’ must be an alias, or a Finder reference, to an existing disk or folder.

Presumably, ‘these_items’ is a list which includes the folder you want to duplicate. If you duplicate ‘these_items’, everything in the list will be duplicated into the ‘images_path’ folder. If the folder you want to duplicate is the only item in the list, that’s fine. Otherwise, you should really duplicate that particular item from the list.

The result of the operation is a Finder reference to the duplicate item (or a list of Finder references, if there’s more than one item) - unless you’re using Mac OS 8.6, which has a bug in this respect.

To call a handler from within a ‘tell’ block, you need to precede the call with ‘my’, so that it’s clear to the compiler that you’re refering to something in the script rather than to something connected with the ‘told’ item:

tell application "Finder"
    -- blah blah blah
    my process_folder(dupli_folder)
    -- more blah
  end tell

  on process_folder(this_folder) -- 'this_folder' is the passed Finder reference
    tell application "Finder"
      -- Do things to this_folder
    end tell
  end process_folder

NG

Hi NG,
In this line:
if folder of the item_info is true then
I think that item_info is information from the ‘info for’ command. The item is probably these_items.
Just guessing, Kel.