How to find MacOS 'Utilities' folder contents with Python
Question:
When calling :
Path('/Applications/Utilities').iterdir()
The returned result is only ‘.localized’ but when I look in the Utilities folder with finder there are many apps – Disk Utility, Airport Utility, etc.
I hav also tried .listdir() with the OS module and same result.
Bigger code sample
def find_apps(directory_item: Path, nested_apps: list) -> None:
if item_is_app(directory_item):
nested_apps.append(directory_item)
return
if item_is_directory(directory_item):
for item in directory_item.iterdir():
find_apps(item, nested_apps)
return
I can’t seem to figure out how to view the apps in the Utilities directory – I don’t have a problem with other folders in the directory. e.g. My Python 3.11 folder correctly produces all apps such as Python Launcher.app and IDLE.app
Answers:
Now the Applications from an OS installation are located in the /System/Applications/
folder. So in your case /System/Applications/Utilities/
.
When calling :
Path('/Applications/Utilities').iterdir()
The returned result is only ‘.localized’ but when I look in the Utilities folder with finder there are many apps – Disk Utility, Airport Utility, etc.
I hav also tried .listdir() with the OS module and same result.
Bigger code sample
def find_apps(directory_item: Path, nested_apps: list) -> None:
if item_is_app(directory_item):
nested_apps.append(directory_item)
return
if item_is_directory(directory_item):
for item in directory_item.iterdir():
find_apps(item, nested_apps)
return
I can’t seem to figure out how to view the apps in the Utilities directory – I don’t have a problem with other folders in the directory. e.g. My Python 3.11 folder correctly produces all apps such as Python Launcher.app and IDLE.app
Now the Applications from an OS installation are located in the /System/Applications/
folder. So in your case /System/Applications/Utilities/
.