Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Count files that start with a certain letter

I need a simple script to give me a count of the files in a certain folder that start with "A" or some other character that I might choose.

I tried this but got an error

count every file name starts with "A" of folder ProofsOutFolder

Thanks for the help.

Posted on Mar 22, 2010 11:30 AM

Reply
Question marked as Best reply

Posted on Mar 22, 2010 11:38 AM

Here:

tell application "Finder"
count (every file of folder "archive" whose name starts with "A")
end tell

(50901)
4 replies

Mar 22, 2010 12:17 PM in response to BenChase

You can also approach it this way...

<pre style="width:630px;height:auto;overflow-x:auto;overflow-y:hidden;"
title="Copy this code and paste it into your Script Editor application.">
set theFolder to choose folder
set theChar to text returned of ¬
(display dialog "Enter Search Character:" default answer "A")
do shell script "find " & quoted form of POSIX path of theFolder & ¬
" -type f -name '" & theChar & "*'|awk 'END{print NR}'"
</pre>

Just another option to try out.

Apr 5, 2010 7:07 AM in response to mahender negi

If you don't care about case you can simply change it to this:

<pre style="width:630px;height:auto;overflow-x:auto;overflow-y:hidden;"
title="Copy this code and paste it into your Script Editor application.">
set theFolder to choose folder
set theChar to text returned of ¬
(display dialog "Enter Search Character:" default answer "A")
do shell script "find " & quoted form of POSIX path of theFolder & ¬
" -type f -iname '" & theChar & "*'|awk 'END{print NR}'"
</pre>

Count files that start with a certain letter

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.