Select only odd (or even) numbered files and move to new folder
I am in need of assistance in creating a script to move files ending in numbers to a new folder if they are odd or even. The files are named like AH1.wav, AH2.wav ...AH12.wav ...AH111.wav, etc.
I have found a script that moves every other file in a selected folder to another selected folder:
set srcFldr to (choose folder with prompt "Select the source folder:")
set destFldr to (choose folder with prompt "Select the destination folder:")
tell application "Finder"
set fileList to files of srcFldr
set fileCnt to count fileList
if fileCnt > 1 then
repeat with i from 2 to fileCnt by 2
move item i of fileList to destFldr
end repeat
end if
end tell
The problem is that the files that end up in the destination folder are not only odd or even, so the "order" of the files in the fileList are not in the same order, by name, as they appear in alphanumeric order as described above. I know there is a way to check the character of the file name just before the "." and then use mod 2 on that value to conditionally select and move only even numbered files, but I'm not sure how to script that. Any help would be greatly appreciated!
Macbook, Mac OS X (10.5.8)