The idea here is that the script tells the finder to move ‘every file’ in the folder. It then gets a list of every folder inside the current folder and calls itself. This will repeat through all subfolders until all files are moved.
It doesn’t rely on any kind of object selection in the Finder, so it can run quietly in the background while the user is performing other tasks - something you can’t do it you’re trying to move the selected item in the Finder.
tell application "Finder"
set sourceFolder to folder "MOVE ME" -- of disk "blah", etc.
my moveFilesFrom(sourceFolder)
end tell
on moveFilesFrom(thisFolder)
tell application "Finder"
set filesToMove to every file of thisFolder
repeat with aFIle in filesToMove
move aFIle to folder destFolder
end repeat
set subFolders to (every folder of thisFolder)
repeat with aFolder in subFolders
my moveFilesFrom(aFolder)
end repeat
end tell
end moveFilesFrom
(Ray Barber)