I have hundreds of CSV files stored on a unix / Linux directory. Their names adhere to the following format: MMYYY_foo.csv. For example,
072019_foo.csv
122018_foo.csv
I'm trying to compile and convert these individually to XML using a Perl script. The command takes on the form ./script.pl MMMMYY_foo, so the following commands would need to be executed in the above example:
./script.pl 072019_foo
./script.pl 122018_foo
Rather than executing the perl script for each file individually within UNIX / LINUX I am trying to loop through the files, passing them to the perl script for compiling. Tediously researching SO among other sources I came down to the following ...
find . -type -f -name '*.csv' -exec perl script.pl $('-printf "%f\n"') {} \;
However this does not work. Rather it outputs multiple ".xml". Undoubtedly the file name (minus paths and extensions) is not being passed to the script correctly as in the code example above. I've tried multiple variations of ...
$(-printf "%f\n"')
And I know therein lies my problem. In many instances I'm just getting multiple ".xml". I feel I'm on the cusp of finding the solution. It's just that I'm not understanding the appropriateness of the command line function beyond -exec. So I'm asking for any help as to whether anyone knows the solution.