0

I have the below folder structure in Linux env:

|-- Fixed_Zip
|   |-- ipython_notebooks
|   |   |-- notebook editor for compute_0anXhGEj.ipynb
|   |   |-- notebook editor for compute_aucScores.ipynb
|   |   |-- notebook editor for compute_nG27bM3w.ipynb
|   |   |-- notebook editor for compute_test_scored_scikit1.ipynb

as you can see, I have file names with spaces. How can I loop thought all the subdirectories in Fixed_Zip folder, and perform the command: jupytext --to py {file} ?

One more thing, I'm doing the command from groovy file, so I guess there are some syntax to adjust. I was able to run the below in my private env and it's working:

SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for i in `find . -name '*.ipynb' -type f`; do
                jupytext --to py "$i"
            done
IFS=$SAVEIFS

However, when I did the same in the groovy file:

sh '''
    SAVEIFS=$IFS
    IFS=$(echo -en "\\n\\b")
    for i in `find . -name '*.ipynb' -type f`; do
        jupytext --to py "$i"
    done
    IFS=$SAVEIFS
'''

I got the below error:

    raise InconsistentPath(
jupytext.paired_paths.InconsistentPath: './ipytho' is not a notebook.
arielma
  • 223

1 Answers1

1

"Filenames with spaces" cries out for find and xargs. Read man find xargs and do something like

find Fixed_Zip -type f -name '*.ipynb' -print0 | \
    xargs -0 -r -n 1 jupytext --to py
waltinator
  • 4,865