Output folder contents to .CSV with alphabets removed from filename I would like to turn the contents(filenames) of a folder into a .csv 

My problem is that the files are organised in sets. I only want to output the filename of each set without anything else but the first numbers. 

Desired Output:



Example of files in folder:


10405a.jpg
10405b.jpg
10405c.jpg
160405a.jpg
160405b.jpg
160405c.jpg
2002035-1.jpg
2002035-2.jpg
2002035-3.jpg




I found some code that i modified with no luck.
I assume i have to loop through the files and check for any non-digit characters and pars that somehow. Any help would be much appreciated.   

set src to (choose folder with prompt "Choose source folder where source tree is rooted at")'s POSIX path
    set theCsv to ""
    repeat with i from 1 to number of items in src
        tell application "Finder" to set this_item to displayed name of item i of src
        set this_item to this_item &amp; ",\\n"
        set theCsv to theCsv &amp; this_item
    end repeat
    do shell script "echo " &amp; quoted form of theCsv &amp; " &gt; ~/Desktop/names.csv"
You could try the following example AppleScript code:

set src to quoted form of ¬
    (choose folder with prompt "Choose source folder where source tree is rooted at")'s POSIX path

set shellCommand to ¬
    "cd " &amp; src &amp; " &amp;&amp; echo 'Object #' &gt; \"$HOME/Desktop/names.csv\"; ls | grep -Eo '^[0-9]+' | sort -u &gt;&gt; \"$HOME/Desktop/names.csv\""

do shell script shellCommand




Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.