I'm trying to come up with a short script to edit some csv files. First, I need to replace delimiters, then change encoding to UTF-16. I would like to do this in two steps, saving the results in two different folders, in case something goes wrong.
The first step (replacing delimiters) I've managed to solve like this and it works fairly well:
mkdir ./01_delimiters
find . -maxdepth 1 -type f -name '*.csv' -exec bash -c 'sed -e "s/|/¦/g" -e "s/╬/|/g" "{}" > ./01_delimiters/"{}"' \;
Now I'd like to take all the files from the 01_delimiters folder, change their encoding and save them into a folder ./02_encoding. I've tried several versions of the following but it doesn't work:
mkdir ./02_encoding
find ./01_delimiters -maxdepth 1 -type f -name '*.csv' -exec bash -c 'iconv -f utf-8 -t utf-16BE "{}" > ./02_encoding/"{}"' \;
It finds the files alright, but throws a 'No such file or directory' error for the output. Any ideas how to make this work? I'm using Ubuntu, by the way. Thanks a lot in advance!
Dan