Help with first script please. files, directories, autocomplete

simonharrison at fastmail.co.uk simonharrison at fastmail.co.uk
Sat Oct 7 11:55:45 EDT 2006


Hello everyone. Hopefully someone can point me in the right direction
here. I'm wanting to write a script to open microsoft word and adobe
pdf documents . Here is a little background:

At the company where I work (an inspection firm) all reports of
inspections are saved as word files. A particular file may contain many
reports named like this; 12345A-F.doc. This file contains six reports.
Most inspections also require a technique which is saved as a pdf. The
pdf filename is the identification of the part being inspected.

My command line script will work like this: The user is asked whether
they are searching for a technique or a report

> Find (c)ertificate or (t)echnique

if they press 'c' they are then asked to enter certificate number.
Using the code below, no enter is needed

import msvcrt
print "Find (t)echnique or (c)ertificate: "
ch = msvcrt.getch()
if ch == 't':
  print "Enter technique number: "
elif ch == 'c':
  print "Enter certificate number: "
else:
  print 'command not understood.'
raw_input()

Obviously I will need to wrap this into a function. What I need to know
how to do is save the two directories where the files are stored. if
'c' is selected I want to use that as the directory to search. same for
techniques. What is the best way to do this? I would also like to have
the text autocomplete after maybe three characters, is this possible?
Am I correct in thinking all files would have to be stored in a list
for this to work?

As you can tell I am new to programming. I don't want someone to write
this script for me, just give me some pointers to get going (maybe a
tutorial on the net). Unless someone really wants to write it of
course!

Many thanks and sorry for the long post.




More information about the Python-list mailing list