Reputation: 23
Multiple .dmg files are present in a particular folder,Using python how could i mount those .dmg files iteratively. I tried the following code
import os
path = '/Users/kat/Desktop/pro'
os.chdir(path)
for i in os.scandir(path):
print(i)
os.system("hdiutil attach i")
But i get "hdiutil" command not found error.Any suggestions would be helpful.
Upvotes: 2
Views: 155
Reputation: 207485
I think you want something more like this:
import os, glob
os.chdir('/Users/kat/Desktop/pro')
for i in glob.glob("*.dmg"):
print(i)
os.system(f'hdiutil attach "{i}"')
Python "f-strings" are described here.
Upvotes: 1