This leverages the find
GNU-util and uses python
for
the rest. Since you are running a python script, I am assuming that python is
installed on the system.
Full command below:
find . \( -type f -regextype posix-extended -regex '.*json' \) - exec python -c "import sys; import os; filename, file_extension = os.path.splittext(sys.argv[1]); if not os.path.isfile(filename + '.csv') : os.system('python ~/bin/convert ' + filename + file_extension + ' -fcsv')" {}
searches for files with .json extension
find . \( -type f -regextype posix-extended -regex '.*json' \)
takes the output from the find command and enters it into the python namespace
filename, file_extension = os.path.splittext(sys.argv[1]);
checks if there is a filename with extension .csv, if not runs the convert.py program
if not os.path.isfile(filename+'.csv'): os.system('python ~/bin/convert.py ' + filename+file_extension + ' -fcsv')"
You can put the entire script into a bash script and use \
to break it up into multiple lines as shown here: How can I split a shell command over multiple lines when using an IF statement?