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 & ",\\n"
set theCsv to theCsv & this_item
end repeat
do shell script "echo " & quoted form of theCsv & " > ~/Desktop/names.csv"
cd
to the target directory and, assuming it contains only the target files, use the following compound command:echo 'Object #' > "$HOME/Desktop/names.csv"; ls | grep -Eo '^[0-9]+' | sort -u >> "$HOME/Desktop/names.csv"