0

I am trying to convert all the .docx files in a folder into .txt files.

I use textutil.

textutil -convert txt filepath/*.docx

I tried this and got an "Argument list too long" error.

hy9fesh
  • 589
  • 2
  • 15

1 Answers1

1

You could use find -exec for this:

find filepath \
    -maxdepth 1 \
    -type f \
    -name '*.docx' \
    -exec textutil -convert txt {} +

This finds all files that end in *.docx in the given directory, and runs the textutil command as few times as possible without running into the "argument list too long" error.

Socowi
  • 25,550
  • 3
  • 32
  • 54
Benjamin W.
  • 46,058
  • 19
  • 106
  • 116