0

I have a folder contains both zipped and non zipped files, I want to migrate data in a given format from one place to another in the local mode. I am new in Python so I tried os module for the first time and for accessing all the files in the folder, I am using os.walk for root path, directory list and file lists. It is showing that zipped files are not directories and normal files are directories. When I am printing root path then it is showing in this way

Desktop/shin/archieve
Desktop/shin/archieve\New folder

My code is

for path,dir_list,file_list in os.walk('Desktop/shin/archieve'):
print(path)

I am confused about "Desktop/shin/archieve\New folder" and "Desktop/shin/archieve/New folder" and also why zipped files are considering as files only.

  • 1
    Look at `os.path.sep`. If you're on a Windows machine, it's probably `\\``, which is what it will use when introducing separators into a path. The `/` characters that you provided are left as they are. Zipped files are files. If you want to look at their contents, you will need to unzip them. If you want to do it from Python, look at [Unzipping Files in Python](https://stackoverflow.com/questions/3451111/unzipping-files-in-python/3451150) – Tom Karzes Mar 19 '20 at 17:28
  • Windows Explorer displays zipfiles *as if* they were folders, but they're not really folders. They are files and Explorer is simply saving you the trouble of using a different program to show what is inside them, – BoarGules Mar 19 '20 at 18:07

0 Answers0