On Jun 29, 2013, at 16:00, Dee Dee Sommers <
email@hidden> wrote:
I guess it's THAT clear that I don't have a clue, what I'm doing, huh?
:)
You're doing okay.
The script I came up with (before I received your awesome advice) was just a very simple one:
tell application "Finder"
set sourceFldr to folder "Macintosh HD:Users:deedee:TestingStuff:Mass"
set destFldr to folder "Macintosh HD:Users:deedee:TestingStuff:daymass"
move every file of sourceFldr to destFldr with replacing
end tell
From your examples, though, I guess I need to modify the code some, huh?
There's nothing at all wrong with that.
My personal preference is to use the alias form, because it's more portable.
I also like to see folder (directory) references terminate with a ":".
"Macintosh HD:Users:deedee:TestingStuff:Mass"
"Macintosh HD:Users:deedee:TestingStuff:Mass:"
While this is not required it tells you at a glance that you're dealing with a folder rather than a file. It is also how the system will return an alias to a folder when asked, so it is perhaps more canonically correct in form.
I then went further and tested for what happens if say, the source folder is empty (will the script error out?) no.
Your script will not error; it will produce an empty list as a result.
I would write the script something like this:
-------------------------------------------------------------------------------------------
# Works fine but requires a path change if moved to a different system:
set dFl_A to alias "Ryoko:Users:chris:test_directory:move_dest:"
set sFl_A to alias "Ryoko:Users:chris:test_directory:move_src:"
# (My preference) Relative to a landmark folder and therefore is more portable:
set sFl_B to alias ((path to home folder as text) & "test_directory:move_src:")
set dFl_B to alias ((path to home folder as text) & "test_directory:move_dest:")
try
tell application "Finder"
set moveList to files of sFl_B as alias list
if moveList ≠ {} then
move moveList to dFl_B with replacing
else
error "No files were found to move!"
end if
end tell
on error e number n
set e to e & return & return & "Num: " & n
beep
tell me to set dDlg to display dialog e with title "ERROR!" buttons {"Cancel", "Copy", "OK"} default button "OK"
if button returned of dDlg = "Copy" then set the clipboard to e
end try
-------------------------------------------------------------------------------------------
This includes my generic error-handler.
I like to put references to files and folders up at the top of my scripts, so if I have to change them later they're easy to find. (And this is another reason I use aliases and keep them out of Finder-tell blocks.)
I hope I somehow come to understand the whys of how to address objects.
It becomes old-hat after a while, but I remember being quite confused for a while when I started scripting 20 years ago.
For instance - why does the Finder produce Finder-specific-references that aren't portable to other applications? Why does the OSX Finder not like posix paths?
These are little gotchas that can make you pull your hair out to begin with.
You really need at least one good Applescript reference book (I have several more than that), and it's invaluable to be able to ask questions on the list.