AnsweredAssumed Answered

list APRXs in workspace folder

Question asked by jpilbeam Champion on Jan 23, 2019
Latest reply on Jan 23, 2019 by jpilbeam

I'm in the process of migrating my stand-alone python scripts from ArcMap to ArcGIS Pro. Using PyScripter as an IDE, I was able to successfully set up my environment. I'm using Python 3.6.2 that came with Pro 2.1. 

 

I want to simply list the files in the workspace folder. Line 3 causes an OSError.

import arcpy, os

aprx = arcpy.mp.ArcGISProject(r"Path\to\folder")

#list the APRXs of the workspace folder
for root, dirs, files, in os.walk(aprx):
    for f in files:
        if f.endswith(".aprx"):
            mxd = arcpy.mp.ArcGISProject(os.path.join(root, f))
            print("current map being checked is  " + f)

 

How do I create a variable for the workspace folder for Pro? Here's how I would've done it for ArcMap:

ws = arcpy.env.workspace = r'path\to\folder'

Outcomes