I have a program that needs to run an command on all the files in a folder:
import glob
import os
dirName = "../pack"
if not os.path.exists(dirName):
os.mkdir(dirName)
os.chdir("xml/")
files = []
for file in glob.glob("*.xml"):
files.append(file)
os.chdir("..")
filearchiver_cmdline = "archiver.exe"
for myFile in files:
filearchiver_cmdline += " xml\\" + myFile
os.system( filearchiver_cmdline )
The command should look like this:
Arhiver.exe file1.xml
What should I change / optimize for this code? Would a class be needed? Should there be logical def-s? Are the variables name good?