Creating docs with Python

Another extension to what I wrote last night, mainly for my own purposes so I don't forget what I did or where I put scripts.

bash is great, but it doesn't play so well with Windows. I tried Cygwin, which installed fine, but on the school computers, filesystems are locked down somewhat and I can't get access to certain install directories. Rather than fight the system, I translated my bash script from yesterday into Python so it works on any OS.

makedoc.py

print "You are about to make a batch of files."

num = int(input('How many files do you want to make?: '))
name = raw_input('What should the base filename be?: ')

for i in range (1,num+1):
  filename = name + str(i) + '.doc'
  print 'Made ' + filename
  i = open(filename,"w").close()

This works nearly the same, only I didn't make it executable like I did the other script. The other thing this does is makes it easier to use the Google Drive API to create docs right in Drive rather than upload .doc files up to Drive and then wait for a conversion.

Leave a Reply

Your email address will not be published. Required fields are marked *