Skip to content

Instantly share code, notes, and snippets.

@danmaps
Last active March 16, 2017 14:38
Show Gist options
  • Save danmaps/3386633ff031bd95fae9bd6a982fad88 to your computer and use it in GitHub Desktop.
Save danmaps/3386633ff031bd95fae9bd6a982fad88 to your computer and use it in GitHub Desktop.
import glob, os
def batchfile(script_folder, batchfile_folder, pyexe):
os.chdir(script_folder)
for file in glob.glob("*.py"):
script = os.path.splitext(file)[0]
batch = batchfile_folder+script+".bat"
with open(batch, 'w+') as f:
print batch
f.write("echo executing with "+pyexe+"\n")
f.write(pyexe+" "+os.path.abspath(file))
print "complete"
if __name__ == '__main__':
batchfile(r"path2scripts", r"path2bats",r"path2pyexe")
#batchfile(r"C:/scripts", r"C:/scripts/batchfiles/", "C:\Python27\ArcGIS10.5\python.exe")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment