Rename of .mdb file -- lock

noydb jenn.duerr at gmail.com
Thu Dec 11 21:43:00 EST 2008


On Dec 11, 9:38 pm, "gudonghua+pyt... at gmail.com" <gudong... at gmail.com>
wrote:
> On Dec 12, 10:15 am, noydb <jenn.du... at gmail.com> wrote:
>
>
>
> > All,
>
> > I have the code below, which unzips a zipfile containing only one
> > file.  Once it is unzipped, I want to rename the file based on a user
> > provided name.  But I get this (WindowsError: [Error 32] The process
> > cannot access the file because it is being used by another process)
> > error, which does not make sense to me as no other apps are open.
>
> > Any suggestions?
>
> > Thanks!
>
> > ****CODE****
> > # Declare the zip file directory and name (shouldn't change, in a
> > permanent location)
> > mdb_zip = ("C:\\ProjWork\\mdb_geoDB_91.zip")
>
> > output_dir = ("C:\\Temp")
>
> > # ZipFile for read
> > z = zipfile.ZipFile(mdb_zip, 'r')
> > zFile = z.namelist()
>
> > # Put contents of zipfile into a list
> > zList = z.namelist()
>
> > # Loop thru list, write zipfile contents to new directory
> > for zItem in zList:
> >     print "Unpacking",zItem
> >     zRead = z.read(zItem)
> >     z1File = open(os.path.join(output_dir, zItem),'wb')
> >     z1File.write(zRead)
> >     z1File.close
>
>      z1File.close()
>
>
>
> > print "Finished extracting zip file"
>
> > uChoice = "test44.mdb" ## to be user chosen someday
> > new91mdb = os.path.join(output_dir, zItem) # C:\TEMP\GDB_9_1.mdb
>
> > ##os.rename(new91mdb, (os.path.join(output_dir, uChoice)))
> > os.rename(new91mdb, (os.path.join(output_dir, "C:\TEMP\test1.mdb")))
>
> > del new91mdb- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

Thanks!  That was simple enough.

And...
##os.rename(new91mdb, (os.path.join(output_dir, uChoice)))
os.rename(new91mdb, (os.path.join(output_dir, "C:\TEMP\test1.mdb")))

... of those two lines, the top one worked.



More information about the Python-list mailing list