In Windows 7 Pro, I need to traverse directories at a given location (in this case Z:\) and perform command prompt commands in each using Python. This seems like it should be straightforward with os.walk()
, but nothing I've tried so far has worked--the closest I've gotten is to have the commands infinitely loop from my desktop (that script is below). What do I need to do to accomplish this task?
import os
for root, dirs, files in os.walk("Z:/"):
for dir in dirs:
os.system('cd Z:\\' + dir)
os.system('git init')
os.system('git add .')
os.system('git commit -m \"Initial\"')