Moving certain number of files from folder to folder

I have a process that needs to move a certain number of files in a folder to a new folder. For instance, there maybe 10 files in a folder and I need the first 5 in one folder and the next 5 in another folder.

I have a script that will do that with a big repeat and move for each interation, but that is time consuming. Does anyone know how a person can do that with applescript?

I really need your help…


set fromfolder to choose folder {}
set tofolder to choose folder {}

tell application "Finder"
	set theThumbFiles to every file of folder fromfolder whose name does not start with "." and (file type is "TIFF" or file type is "JPEG" or name extension is "tiff" or name extension is "tif" or name extension is "jpeg" or name extension is "jpg")
	move file (items 1 through 5 of theThumbFiles) to folder tofolder
end tell

That worked great - Since that was so easy I would like to copy the files to another folder. I tried with the below script, but the copy doesn’t seem to work. Can you give me some guidance on this one also?

Thank you in advance.



set fromfolder to choose folder
set tofolder to choose folder
set thirdfolder to choose folder
tell application "Finder"
	set theThumbFiles to every file of folder fromfolder whose name does not start with "." and (file type is in {"TIFF", "JPEG"} or name extension is in {"tiff", "tif", "jpeg", "jpg"})
	set x to count theThumbFiles
	copy (items 1 thru 5 of theThumbFiles) to thirdfolder
	move (items 1 thru 5 of theThumbFiles) to tofolder
end tell

Sorry that was a silly post.

Here is the code to do that.



set fromfolder to choose folder
set tofolder to choose folder
set thirdfolder to choose folder
tell application "Finder"
	set theThumbFiles to every file of folder fromfolder whose name does not start with "." and (file type is in {"TIFF", "JPEG"} or name extension is in {"tiff", "tif", "jpeg", "jpg"})
	set x to count theThumbFiles
	--copy (items 1 thru 2 of theThumbFiles) to thirdfolder
	move (items 3 thru -1 of theThumbFiles) to tofolder
	copy entire contents of folder tofolder to folder thirdfolder
end tell