recursive source tree checkin script
To recursively check in file in Perforce, wrote the following python script called kzP4Add.py
import os, sys
def visit(arg, dirname, names):
for n in names:
r = os.spawnl(os.P_WAIT, r"C:\Program Files\Perforce\p4.exe", r"p4", "add", '"'+os.path.join(dirname, n)+'"')
print r, dirname, n
def Main():
if len(sys.argv) != 2:
print "Usage is kzP4Add "
for a in sys.argv: print a
return
absdir = os.path.abspath(sys.argv[1])
os.path.walk(absdir, visit, 0)
if __name__ == "__main__":
Main()
Its key that the first argument is the program name, excluding the path info.
Adding the quotes around the filename argument is necessary if the path or name can contain spaces.
The client doesn’t need to be specified.