That's correct, the 'find' command is likely the easiest way to accomplish what you want. I can give a couple of examples. Using find with "-exec" causes the find command to execute the given command on each file. When doing this, it will replace {} with the filename. That's why you see that sequence in command examples. The find command takes a directory name as its primary argument. If you already used a 'cd' command to get to the appropriate directory, then "." is the current directory. The find command traverses the complete directory structure under that directory, so I suggest using the -print command to verify the list of files it is going to act on.
Print all files called "*.txt" under the current directory:
Code:
find . -name '*.txt' -print
Convert all *.txt files under the directory "filedir" and put the output into a file name appended with .utf8:
Code:
find filedir -name '*.txt' -print -exec iconv -f MACROMAN -t UTF-8 "{}" > "{}.utf8" \;
Convert all files under the directory filedir and place in the directory "results" under your home directory:
Code:
find filedir -type f -print -exec iconv -f MACROMAN -t UTF-8 "{}" > ~/results/"{}" \;
If you need to edit the pathname of the output files, then you will likely need a more complicated shell script that creates the final path you are looking for.
You can test the commands that find is going to do by adding 'echo' to the front of it. I'd recommend you do that until you get used to how find works.
Code:
find filedir -type f -exec echo iconv -f MACROMAN -t UTF-8 "{}" > ~/results/"{}" \;
I put double quotes around the paths in the example command because if the file or directory names have spaces in them, then the double quotes are needed.