I have a simple program that searches for all compressed folders in a directory, targets one compressed file, gets the excel file located inside the compressed file, and moves it to another location (it does this for every excel file, for which many ever compressed folders):
path = 'C:\Users\me\Documents\Extract' new_path = 'C:\Users\me\Documents\Test' i = 0 for folder in os.listdir(path): path_to_folder = os.path.join(path, folder) zfile = zipfile.ZipFile(os.path.join(path, folder)) for name in zfile.namelist(): if name.endswith('.xls'): new_name = str(i)+'_'+name new_path = os.path.join(new_path, new_name) zfile.close() #os.rename(path_to_folde, new_path) -- ERROR HERE shutil.move(path_to_folde, new_path) -- AND ERROR HERE i += 1
I tried 2 ways to move excel os.rename and shutil.move . I keep getting the error:
WindowsError: [Error 32] The process cannot access the file because it is being used by another process.
I do not understand why this error persists since I closed every folder.
python
Max kim
source share