0

Basically i'm trying to print all excel files in a directory. In one of the folders, i don't have a excel file named '~$EndManifold-4Slot.xlsm', but while printing the files, i see this is present, which is actually not there.

Could anyone suggest on how to improve the same?

        def Fnfolders(rootdir):
            xlFilesList=[]
            for dirname, dirnames, filenames in os.walk(rootdir):
                for file in os.listdir(dirname):
                    if '.xls' in file or '.xlsx' in file:
                        fullPath=os.path.join(dirname)+"\\"+file
                        xlFilesList.append(fullPath)
            return xlFilesList

        xlFilesList=Fnfolders(rootdir)
        for excel in xlFilesList:
            print (excel)
  • I tried renaming the excel file in that specific folder to some other name too, but still not successful. I opened task manager to see if anything is catching around. I don't see any files hanging there. – Vijay k Gopikrish Aug 27 '15 at 04:45
  • 1
    It is definitely present. Ensure you have enabled showing of hidden files in Windows Explorer. – metatoaster Aug 27 '15 at 04:48

1 Answers1

2

Normally, files like - ~$EndManifold-4Slot.xlsm are temporary files created when you openned your file in Excel. they are usually hidden, you can find them in your explorer if you enable Show Hidden Files in folder options.

You can read more about those temporary files here .

Anand S Kumar
  • 88,551
  • 18
  • 188
  • 176