經常希望可以執行一個命令行N次。。。windows下沒有現成的工具(有?推薦給我!)
用python寫一個。。。
#!/usr/bin/evn python #coding: utf-8 """ times.py run a command line for n times """ import os import sys import string if __name__ == "__main__": n = 1 cmd = "" if len(sys.argv) >= 3: n = int(sys.argv[1]) cmd = string.join(sys.argv[2:], ' ') else: print '''error command line Useage: times n "command line" ''' exit(1) for x in range(n): os.system(cmd)
實現效果
C:\Users\hydon>times 10 echo hello world. hello world. hello world. hello world. hello world. hello world. hello world. hello world. hello world. hello world. hello world.