Search code examples
command-linetextutils

Argument list too long for textutil conversion


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.


Solution

  • 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.