Parse folder of files and report odd file sizes in text file.

Howdy! I’d be grateful for some help. The goal is to allow the user to navigate to a folder, whereby the script looks at all the .tif files inside and creates a list (in textedit preferably) of the files not being a specific size. I’ve got the below so far, and clearly I’m a ways off.
Thank you for your time.

KB

tell application "Finder"
	set theFolder to choose folder
	set oddfiles to (every item of theFolder whose name extension is "tif" and size is not equal to 2390220)
	display dialog (oddfiles as string)
end tell

Hi,

your script tries to display the file specifiers, not the names of the files


tell application "Finder"
	set theFolder to choose folder
	set oddfiles to (name of every item of theFolder whose name extension is "tif" and size is not equal to 2390220)
	set {ASTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
	set oddfiles to oddfiles as Unicode text
	set AppleScript's text item delimiters to ASTID
	display dialog oddfiles
end tell
set deskPath to path to desktop as Unicode text
set filePath to deskPath & "OddFiles.txt"
tell application "Finder"
	set theFolder to choose folder
	set oddfiles to (name of every item of theFolder whose name extension is "tif" and size is not equal to 2390220)
end tell
set atid to AppleScript's text item delimiters
set AppleScript's text item delimiters to {return}
set fileRef to (open for access file filePath with write permission)
write (oddfiles as text) to fileRef starting at eof
close access fileRef
set AppleScript's text item delimiters to atid

Thank you for the quick replies, much appreciated. Here comes the however…
When I run your script(s) I get a list of all files in the directory, not the one that I purposely made a different size. To come up with the number, I used the bytesize that I received from the ls -l command. To test I made one .tif that was smaller. My goal is to have a script that indicates the “odd man out.” Interestingly it seems that the .tif filter works great but the file size one does not. Did I make an error in the choice of “size” as the parameter to use?

Again, I appreciate your time.

KB

Ahh thats it… you’re going to get different sizes from the terminal than you will finder.

Run this and choose one of the files of the “correct” size

set x to choose file
tell application "Finder"
	set fSize to size of x as integer
	display dialog fSize
end tell

Now replace 2390220 with the size given back to you and try again :slight_smile:

Great, thank you James, now I’m all set.