Thanks Dan.
No errors, but still not seeing PDFs saved to the outFolder. There are two APRXs in this test folder. And as before running this script saves one PDF not in the TestFolder2 folder, but one spot back. And the PDF is named "TestFolder2". Here's the whole thing again with the print statements below it.
import arcpy, os
rootDir = r"path\to\TestFolder2"
outfolder = r"path\to\TestFolder2"
for dirName, subdirList, fileList in os.walk(rootDir):
for file in fileList:
if file.endswith(".aprx"):
current_aprx = arcpy.mp.ArcGISProject(os.path.join(rootDir, file))
pdf_name = os.path.join(outfolder, file[:-4])
for cnt, lyt in enumerate(current_aprx.listLayouts()):
print(lyt.name)
lyt.exportToPDF(outfolder)
print("exporting APRX to PDF: {}{}{}".format(pdf_name, cnt, ".pdf"))
current_aprx.save()
del current_aprx
MUNICIPAL_LIMITS_A
exporting APRX to PDF: path\to\TestFolder2\MUNICIPAL_LIMITS_A - Copy.0.pdf
MUNICIPAL_LIMITS_A
exporting APRX to PDF: path\to\TestFolder2\MUNICIPAL_LIMITS_A.0.pdf