As a beginner, its time to meet your new friend, the Result window. Open the result window from the Script Editor menu, “Show Result”.
Now, run these one at a time and look at the result. That is what you have successfully (or not) communicated to Applescript.
set target_folder to choose folder
That’s not just the folder name, it’s a full path to it.
list folder gives you the item names, not the paths. You will get the names, but not be able to do anything with them. You need a file returned with a full path:
set target_folder to choose folder
set target_files to every file of target_folder
Popped up an error, didn’t it? That’s because now your doing a Finder job.
set target_folder to choose folder
tell application "Finder"
set target_files to every file of target_folder
end tell
See how the result is not only filenames, but the paths to them as well? That’s what you need to move files. The folder they move to needs to be a full path as well.
So-
FilesFolder is a folder you select. I set theFiles to every file of FilesFolder. In the first repeat loop, each file is processed one by one, by the name I gave it, ‘thisFile’.
Archive is a folder you select. I set theFolders to every folder of archive. In the second repeat loop, each folder is processed one by one, by the name I gave it, ‘thisFolder’.
So you see the pattern for the repeat loop needs no count, because you’ve defined how many times with
repeat with Any_Variable in A_List
–actions
end repeat
You can name the variable anything that isn’t an AS term, ie you can’t use the word “item”. That variable will be the reference to each list item, so choose it’s name to help you.
SC