I’d like to be able to loop over all of the files within a directory (the one the script is in) and extract portions of the name and turn it into CSV readable.
From:
ch-026-Metallic-Morphing Mauve-14pt.jpg
To:
ch-026, Metallica-Morphing Mauve-14pt
…or however Excel or Numbers would be able to read it.
At the request of a couple of you, I’ll clarify that I want to cut out the second “-” dash and replace it with a comma and space.
First, use
to scan the directory. Then loop like this
Finally, use preg_match to match entries. Generally:
In your case a pattern like
might do the job.
Finally, use the information provided in $matches to write the CSV file.