docx2pdf
docx2pdf copied to clipboard
Recursively convert all files in a directory tree
Great tool! Is there a way to convert all files in all subfolders of the given input folder?
Great suggestion! I don't think it works recursively at the moment but that's definitely something we can add.
For the time being you might be able to run this command:
find . -name "*.docx" | xargs -L 1 docx2pdf
In my test on macOS, I got a lot of pop-ups asking to grant permissions so you might want to run docx2pdf
on one of the file in the root folder before using the snippet above; hopefully that might reduce the number of permission pop-ups?

This works in Mac but not in Windows - Windows has no xargs..
Great suggestion! I don't think it works recursively at the moment but that's definitely something we can add.
For the time being you might be able to run this command:
find . -name "*.docx" | xargs -L 1 docx2pdf
In my test on macOS, I got a lot of pop-ups asking to grant permissions so you might want to run
docx2pdf
on one of the file in the root folder before using the snippet above; hopefully that might reduce the number of permission pop-ups?![]()
you can add param --keep-active to avoid word alway activate(I find it by run docx2pdf in termimal ,i see hint,hope this is useful to person that process a lot of file ).
a lot of pop-ups
when you face a lot of pop-ups ,how to solve? waiting for you to reply,thanks
@zeguangzhang I believe if you run docx2pdf
on a single file in a directory, macOS Catalina should ask for a single pop-up giving the program permission to the entire folder. Once that is done, all future files in that same folder shouldn't require any permission pop-ups.
Can you verify if that works for you?
@zeguangzhang I believe if you run
docx2pdf
on a single file in a directory, macOS Catalina should ask for a single pop-up giving the program permission to the entire folder. Once that is done, all future files in that same folder shouldn't require any permission pop-ups.Can you verify if that works for you?
accordding to you said,I try it ,but no giving the pop-up permission to the entire folder. i continue believe you said,add some docx files to directory,but still to pop-up always.
perhaps you can run it on the top level folder once (which will only handle the first level)
and then run it again via xargs to see if that removes the pop-ups?
On Sat, Apr 25, 2020 at 1:17 AM zeguangzhang [email protected] wrote:
@zeguangzhang https://github.com/zeguangzhang I believe if you run docx2pdf on a single file in a directory, macOS Catalina should ask for a single pop-up giving the program permission to the entire folder. Once that is done, all future files in that same folder shouldn't require any permission pop-ups.
Can you verify if that works for you?
accordding to you said,I try it ,but no giving the pop-up permission to the entire folder. i continue believe you said,add some docx files to directory,but still to pop-up always.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/AlJohri/docx2pdf/issues/3#issuecomment-619323146, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVJFTDZJOR6WHQ45FCOLPTROJW5HANCNFSM4KYWTP3A .
The first time I ran it, I was overwriting an existing PDF. I had to navigate the "Grant Access" popup flow to let Word access the input file, and then a second popup flow to let Word access the output file. There was no way to change the permission, mid-flow, to apply to the containing folder.
The next time I ran it, the output path didn't exist yet, and the permission popup asked me to grant Word access to the whole folder. That caused subsequent popups to write to that folder to go away.
After that, I still get prompted for each specific input file (even though they're in the same folder I am writing out to, that Word now has permissions to!).
Wondering if there's a way for docx2pdf
to request access to the whole folder explicitly (this could be configurable via CLI flags).
Just had a chance to try pointing docx2pdf
at a whole folder:
docx2pdf <folder>
it seems that this does what I hoped above: it asks me to grant Word permissions on the whole folder, so that subsequent docx2pdf
conversions of individual files in that folder are fully automatic.
It also converts all .docx
s to .pdf
s "in place" (basenames are kept the same except for the extension), so that's a nice bonus.
Thanks @AlJohri!
The first time I ran it, I was overwriting an existing PDF. I had to navigate the "Grant Access" popup flow to let Word access the input file, and then a second popup flow to let Word access the output file. There was no way to change the permission, mid-flow, to apply to the containing folder.
The next time I ran it, the output path didn't exist yet, and the permission popup asked me to grant Word access to the whole folder. That caused subsequent popups to write to that folder to go away.
After that, I still get prompted for each specific input file (even though they're in the same folder I am writing out to, that Word now has permissions to!).
Wondering if there's a way for
docx2pdf
to request access to the whole folder explicitly (this could be configurable via CLI flags).
But it is still an error. I still get prompted for each specific input file (even though they're in the same folder I am writing out to, that Word now has permissions to!). Can author fix this error?
I am having the same problem when using convert()
. When running the project, Word opens each input file and asks for permission of this specific folder although I granted Word and Pycharm permission for every folder on my Mac. Is there a workaround as long as its not fixed? Can I use docx2pdf <folder path>
inside a Python project somehow?
Same problem here, two windows are showing up and I have to give permission to every single file. Would be great if this could be solved!
Original comment: Still an issue here in 2023!
Edited comment: I’m having permissions related issues where I’m prompted to give Microsoft Word permission to access a folder or file. Even if I try to use the recommended strategy here.
Steps I have taken and where the issue arises:
- Create a parent folder
- Run convert() on the parent folder
- A pop up appears on Microsoft Word requesting permission to access the parent folder
- Provide permission to the parent folder via the pop up
- Create a sub folder within the parent folder with new .docx files that need to be converted
- Run convert() on the parent folder
- Issue: a pop up appears requesting for permission for the sub folder even though permission was granted previously for the parent folder containing the sub folder
Summary: Every time a new sub folder is created within the parent folder where permission was granted to, a new pop up occurs where permission is requested for every new sub folder that was created.
Question: Is it possible to avoid having to provide permission for every new sub folder with .docx files that need to be converted? Running convert() avoids having to provide permission on every file which saves a lot of time, but it is still quite tedious having to provide permission for every sub folder.
@nmoton not a super helpful comment! please use the +1 feature for this. can you add some more details? are running into permissions issues or something related to recursively converting files in a directory tree?
if its permissions, did the workaround described here not work? https://github.com/AlJohri/docx2pdf/issues/3#issuecomment-633138973
this should grant permissions to the entire folder instead of each file individually
@nmoton not a super helpful comment! please use the +1 feature for this. can you add some more details? are running into permissions issues or something related to recursively converting files in a directory tree?
if its permissions, did the workaround described here not work? #3 (comment)
this should grant permissions to the entire folder instead of each file individually
You’re right about my comment being unhelpful. Sorry about that.
I edited my original comment and provided more context. You can see the changes here.
(Sometimes when using forum boards to ask for help, I can forget that the same communication-based rules apply when asking for help from colleagues. My bad!)
Hi here, any progress here?
I am still seeing behavior like @HebeTienCoder describes on my MacOS 12.6 machine. docx2pdf /path/to/dir
still requires $n$ permission grants for $n$ .docx
files in dir
. WITS the workaround described at #3 (comment) did not work.
In my effort to solve this, I have given the following Full Disk Access:
- Word,
- my current installation of python, at
/opt/homebrew/opt/[email protected]/bin/python3.11
, since that's hardcoded into/opt/homebrew/Cellar/docx2pdf/0.1.4/libexec/bin/docx2pdf
in my install -
/usr/bin/osascript
since that's howconvert.jxa
gets called - Terminal
- bash
Despite this, however, docx2pdf still errors or hangs, waiting on manually needing permissions granted.
It's not clear to me what permissions Word is lacking, or where it registers the new permissions it gains when I manually click ok.
any updates? this still requires to give permissions over and over again...