Selecting a certain amount of files

I hope someone can help me with this. I have a folder with jpegs and need to select a batch of files, which is then moved into another folder. Unfortunately I cannot find any solution to how to select a given amount of files. In my current solution I move the first file in the folder (sort after creation date) 76 times into a folder, but this is time-consuming.

Thanks for any advice.



tell application "Finder"
	
	set sourceFolder to choose folder
	
	
	
	set theFiles to count of (files in folder sourceFolder)
	
	if theFiles = 152 then
		
		set obvFolder to (make new folder at sourceFolder with properties {name:"o"})
		
		repeat until (theFiles = 76)
			
			set latestFile to item 1 of (sort (get files of sourceFolder) by creation date) as alias
			select latestFile
			set theSelection to first item of (get selection)
			
			move theSelection to obvFolder
			
			set theFiles to count of (files in folder sourceFolder)
			
		end repeat
		
	end if
	
	
end tell




Hi,

do you mean this


set sourceFolder to choose folder

tell application "Finder"
	set theFiles to sort (get files of sourceFolder) by creation date
	-- set latestFile to item 1 thru 15 of 
	if (count theFiles) = 152 then
		set obvFolder to (make new folder at sourceFolder with properties {name:"o"})
		move items 1 thru 76 of theFiles to obvFolder
	end if
end tell

A million thanks :slight_smile: I didn’t come across the element “thru”. It works perfectly. Great.