Find Folders (Python)¶
Find Folders (Python)¶
1impact.gui.output_toolbox.clear()
2projects = impact.active_database.projects
3
4# Find a "1. Production" folder in the projects folder
5folder1 = None
6try:
7 folder1 = projects.find("1. Production")
8except Exception as exc:
9 impact.gui.output_toolbox.add(f"Failed to create object via projects.find(): {exc}")
10
11if not folder1.isNone():
12 impact.gui.output_toolbox.add("Successfully found '" + folder1.folder_name + "'")
13else:
14 impact.gui.output_toolbox.add("Unable to find folder")
15
16# Find a "1. Production\2005\\January" project folder using a full path
17folder2 = projects.find_child_by_display_path("1. Production\2005\\January")
18
19if not folder2.isNone():
20 impact.gui.output_toolbox.add("Successfully found '" + folder2.display_path + "'")
21else:
22 impact.gui.output_toolbox.add("Unable to find folder")
23
24if not folder1.isNone():
25
26 # Find a r"2005\\January" folder using a relative path from folder1
27 folder3 = folder1.find_child_by_display_path(r"2005\\January")
28
29 if not folder3.isNone():
30 impact.gui.output_toolbox.add("Successfully found '" + folder3.display_path + "'")
31 else:
32 impact.gui.output_toolbox.add("Unable to find folder")