'pandoc or libreoffice for multiple .docs to pdf in R

I am trying to batch convert documents from .docx to .pdf in R. My documents are contained in the following file structure: Level 1 Folders --> Level 2 Folders ---> Files Within the level 2 folders, some files are already pdf and others are document.

I'm wondering if there is a way to set up pandoc file path command that it reads which files are .docx within a level 2 folder and then converts those.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source