nb-clean icon indicating copy to clipboard operation
nb-clean copied to clipboard

Support batch and wildcard file names

Open yasirroni opened this issue 1 year ago • 2 comments

Support this feature:

nb-clean clean --preserve-cell-outputs  notebooks/*

It first will list all .ipynb files in notebooks/, then iteratively clean all the notebooks.

yasirroni avatar Aug 29 '22 04:08 yasirroni

This should already work if globs are expanded by your shell, which they typically are by default in shells like bash and zsh. For example:

$ ls -1 notebooks         
dirty-1.ipynb
dirty-2.ipynb
$ nb-clean check notebooks/*
dirty-1.ipynb cell 0: metadata
dirty-1.ipynb cell 0: execution count
dirty-1.ipynb cell 0: outputs
dirty-1.ipynb metadata: language_info.version
dirty-2.ipynb cell 0: metadata
dirty-2.ipynb cell 0: execution count
dirty-2.ipynb cell 0: outputs
dirty-2.ipynb metadata: language_info.version

However, it would be useful to be able to pass a directory name without a glob (e.g. nb-clean clean notebooks) and have nb-clean operate on that recursively: PRs for this would be welcome.

srstevenson avatar Aug 29 '22 07:08 srstevenson

I'm using Windows powershell and the above code is not working (nb-clean clean --preserve-cell-outputs notebooks/*).

yasirroni avatar Aug 29 '22 08:08 yasirroni

@yasirroni This should be resolved by #148, but I haven't been able to test on Windows with PowerShell. If you have problems in that environment, please open a new issue.

srstevenson avatar Sep 25 '22 14:09 srstevenson