Skip to content

Instantly share code, notes, and snippets.

@griloHBG
Last active May 25, 2022 15:42

Revisions

  1. griloHBG revised this gist May 25, 2022. No changes.
  2. griloHBG created this gist May 25, 2022.
    11 changes: 11 additions & 0 deletions all_PDF_to_text.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # making sure that names with spaces won't be a problem
    IFS=$'\n';

    # head to remove the last 2 lines (one blank and one summary) and tail to remove the first line (always a dot) of tree output
    # TODO: what about *.PDF?
    for i in $(tree . -f -P "*.pdf" -i | head -n -2 | tail -n +2);
    # echo the relative file path
    do echo -n "${i}: ";
    # if it is a file (and not a directory), perform the conversion
    [ -f ${i} ] && echo PDF && pdftotext "${i}" "${i}.txt";
    done