-1

Could anyone help how to copy one specific folder to each subfolder of another folder in applescript? Here is what I have based on Tim Joe's request.

tell application "Finder"
    set _folder to choose folder
    set _destination to choose folder
end tell
tell application "Finder"
    set _listOfDest to (every folder of _destination) as alias list
    set _subfolders to value of _listOfDest as list
    set i to 1
    repeat
        duplicate _folder to _subfolders
        set i to i + 1
    end repeat
end tell

It seems to return an error "Can’t get value of {alias [...]"

Tim Joe
  • 475
  • 8
  • 18
  • Typically asking for handouts with out giving any attempt at the code will give you negative feedback. – Tim Joe May 12 '14 at 15:31

1 Answers1

1

Here I will get you started...

set SelectedFolder to (choose folder)
set DestFolder to (choose folder)
tell application "Finder" to move folder SelectedFolder to folder DestFolder

Update:

First I would clean up a few things.

  • You don't need a tell block to get an alias. So I would remove the first tell block you have.
  • In line 7, "Value of" is not a term so your script is going to break there.
  • Nice set up for repeat useing "i" and increasing it every repeat
  • Never ever use a repeat without declaring an escape or it will run forever (or until it maybe will times out).

The Tweaks.

  • Variable _listOfDest is already a list of every sub-folder. You can delete the line after it.
  • Since _listOfDest is a list we can count how many times to repeat and to which folder. Your repeat should like below. (Note:CurrentFolder is the current number you are on between 1 and how many folders are in the list defined by (count _listOfDest))

    repeat with CurrentNumber from 1 to (count _listOfDest)
    
  • Since we define the repeat you can also delete "set i to 1" and "set i to i + 1"

  • Lastly your duplicate looks like the following using the folder use by the repeat

    duplicate folder _folder to folder (item CurrentNumber of _listOfDest)
    

Update your original post with you next version if you need more help

Tim Joe
  • 475
  • 8
  • 18
  • Hi Tim Joe, Thanks for your comment and help! I had tried to search for the solution previously and it led me to a combination of copy and loop. The former seems straightforward, I had trouble with the latter, repeating the copy command for each subfolder of a folder. As you've probably found out I don't know much about scripting, therefore your help is more than appreciated. – user3629004 May 13 '14 at 14:06
  • Try to compile the script and update your post. As a community we like to teach people how things work and why. If you post asking for freebies then we are unable to teach you. Try to use the above info and make a loop that asks for multiple distention folders and includes a move to that folder. – Tim Joe May 13 '14 at 15:54
  • Point taken, thanks for your guidance. Here is what I could come up with, but it returns an error "Can’t get value of {alias [...]" tell application "Finder" set _folder to choose folder set _destination to choose folder end tell tell application "Finder" set _listOfDest to (every folder of _destination) as alias list set _subfolders to value of _listOfDest as list set i to 1 repeat duplicate _folder to _subfolders set i to i + 1 end repeat end tell – user3629004 May 13 '14 at 22:16