I want to convert the coding of some csv-files with iconv
. It has to be a script so I am working with while; do done
. The script lists every item in a specific directory and converts them into another coding (utf-8).
Currently, my script lists EVERY item, including directories... So here are my questions
Does
iconv
has a problem with directories or does it ignore them?And if there is a problem, how can I only list/search only for files?
I tried How to list only files in Bash? a ***./***
at the beginning of every item and that's kinda annoying (and my program doesn't like it, too).
Another possibility is ls -p | grep -v /
but this would also affect files with / in the name, wouldn't it?
I hope you can help me. Thank you.
Here is the code:
for item in $(ls directory/); do
FileName=$item
iconv -f "windows-1252" -t "UTF-8" FileName -o FileName
done
Yea, i know, the input and output file cannot be the same^^