This is my first time posting anything here, so if I forget something or you need more info to answer my question, please let me know.
So I am trying to make a small bash script, that echoes all files in a folder into an array using a for-loop.
The snippet looks like this:
romList=(*)
for line in *
do
romList+="($(echo "$linen"))"
done
Then when I try to echo out each value with this code:
for entry in "${romList[@]}"
do
echo $entry
done
I get a result that looks like this:
$ file1 file2 file3
file2
file3
So for the first iteration it puts all of the files found into the first value and then continues as expected for the subsequent iterations.
For context I am trying to cleanup my roms folders, by removing language descriptions in the individual filenames. So my plan was to echo the filename into an array as a string, check up against an array of patterns and then remove that pattern from the string, so I can use it as a new filename.
That also means that the filenames have spaces and parenthesis in them, but I don’t understand if that should affect only the first iteration.
If you have another (read better) solution for achieving that, also please let me know.
anistorian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.