Reviewing what you mentioned, seems extremely simple. Even moreso than Automator in a way
In my opinion, AppleScript is easier - it's certainly easier to string together multiple discrete tasks, plus it's easier to read that one line and understand it's purpose than it is reading each step in an Automator workflow and knowing what it's trying to do.
what if there are no files of that filetype left in the folder and there are only
That's a fair question, right now, as it stands, it would throw an error ("can't get every file of folder.."). There are multiple ways of dealing with that. One is to add a specific test to check that files exist, another is to assume the best and just catch errors.
To specifically check that some files were found the script needs to be expanded some:
tell application "Finder"
set files2Move to (every file of folder "Split Filetypes" of desktop whose name extension is "wav")
if count files2Move > 0 then
move files2Move to folder "Path:to:your:WAVs"
end if
end tell
Here the first statement gets a list of matching files and puts them in a variable I've called files2Move.
I then check to make sure that files2Move actually contains some data (i.e. there aren't 0 files). If there are any files, I move them. If there are no files the move statement never executes.
The alternative approach is to use a 'try' statement. This tells AppleScript to fail gracefully, rather than reporting an error, so in this case I can just try to move the files and ignore any failures:
tell application "Finder"
try
move (every file of folder "Split Filetypes" of desktop whose name extension is "wav") to folder "Path:to:your:WAVs"
end try
end tell
Here I've wrapped the move command in a try/end try block. If an error occurs the script moves silently to the 'end try' statement without reporting an error to the user. Note that there are multiple things that cold constitute an error - the source or destination directories might be invalid or missing, there might be zero files that match the criteria, the destination directory might be read-only, etc. This script doesn't differentiate between any of those cases, it'll just try its best and move on.
Can I just put in a move function to move those filetypes, written in applescript, that goes on to the next step in automator if no files are found?
You can do that - Automator is built on top of the same underlying engine as AppleScript is. Indeed, there is a Run AppleScript action in Automator, so anything you can do in AppleScript you can add as a step in Automator. My problem with this though, is in passing data between the workflow and the AppleScript action. For me, I find it easier to write in AppleScript, so as soon as I find myself thinking in AppleScript I move the whole project there since integration is just so much easier.
Applicatons and Folder Actions are not Automator-exclusives. Indeed, the original Folder Actions spec was AppleScript entirely - Automator put a slightly prettier front-end on it, but it was originally all AppleScript.
Granted, building a Folder Action in Automator is easier since it takes care of saving the script in the right place and attaching it to the folder in question, but it's not hard to do in 'pure' AppleScript - you just need to add an appropriate handler so that the OS knows what to do when the folder is triggered.
Of course, as a folder action you're no longer concerned with checking a specific directory. Since the folder action is attached to a folder (or, really, any folder) you should check the data that's passed in rather than rely on a hard-coded path.
For example, to turn my script into a Folder Action that triggers on newly-added files, you wrap it like;
on adding folder items totheFolderafter receivingtheNewItems
repeat with each_file in theNewItems
tell application "System Events"
if name extension of each_file is "wav" then
move each_file to folder "Path:to:your:WAVs"
end if
end tell
end repeat
end adding folder items to
Now, this is a little different. Since it's a Folder Action it inherently knows the files that have just been added, so there's no need to query the Finder to find the WAV files - you can just look at the list of files that were passed in. You can just duplicate the 'if name extension... end if' statements for each of your file types, and you don't need to worry about there being zero files to move since the 'if' statements will identify the file types.