Hey Skillet,
Why are you using a property instead of a variable? They have their uses of course, but it’s better to use a simple variable unless you have a specific need for a property.
This is not good practice, because you can never tell when an application will accept a plain path-string.
It’s better to turn the path-string into an actual object:
set _name to "wget_test"
set _parent to "Ryoko:Users:chris:Downloads:"
set _path to _parent & _name
tell application "Finder"
# Good
set myFolder to folder _path
# Better
set myFolder to _path as alias
end tell
Here you’re failing to understand string-concatenation '&". You’re trying to use concatenation within a Finder-Reference, and it just won’t fly.
You would write it like this:
set currentSemester to "fall14"
tell application "Finder"
delete (every document file of folder currentSemester of disk "Athena")
end tell
But again this is a bad practice.
It’s better to do something like this:
set currentSemester to "fall14"
set targetFolderAlias to ("Athena:" & currentSemester) as alias
tell application "Finder"
delete document files of targetFolderAlias
end tell
By coercing your path-string to an alias you have a built-in error-check, because it will error if the folder doesn’t exist.
You can also visualize the HFS path of the alias and see if it goes to the right place, and you can test this as well.
When you’re having failures you debug by commenting-out code and running to that point. If it succeeds you uncomment some more code, and run it - and so on. If it doesn’t succeed you comment-out some more code and run to that point.
If your code is too terse it gets more and more difficult to debug and generally isn’t enough faster than more descriptively verbose code to make it worthwhile.
Make your code as easy to read and understand as possible, and you’ll thank yourself a week, a month, or a year from now when you have to work on it again.