Applescript – folder and file counter

Posted by | Posted in Applescript, Code, OS X | Posted on 16-09-2010

set theFolder to (choose folder)
set thePath to POSIX path of theFolder
set fileCount to 0
set folderCount to 0
tell application "Finder"
	set theFileList to every item in folder theFolder
	repeat with x in theFileList
		if not character 1 of ((name of x) as string) is equal to "." then
			if kind of x is equal to "Folder" then -- "folder" depends fromĀ  the finder language 
				set folderCount to folderCount + 1
				set fileCount to fileCount + 1
			end if
		end if
	end repeat
end tell
display dialog "There are " & folderCount & " folders andĀ  " & fileCount & " files in " & thePath

Comments are closed.

Join the mailing list

Check your email and confirm the subscription