Home > Blockchain >  List directories in zip and rar files
List directories in zip and rar files

Time:08-04

I trying to do a data frame/list/vector with a list of folders inside a zip and rar file.

I have a folder with a lot of zip and rar files; Each zip and rar file has one folder and inside this folder has a lot of folders and files; I would get the names of these folders inside a zipped folder;

I try:

unzip(zipfile = "teste1.zip", list = TRUE)

and it show me:

                            Name Length                Date
1                        teste1/      0 2022-08-03 15:49:00
2            teste1/Nova pasta1/      0 2022-08-03 15:50:00
3 teste1/Nova pasta1/texto11.txt      0 2022-08-03 15:49:00
4              teste1/texto1.txt      0 2022-08-03 15:49:00

But I would like to get just the names of second directory (Nova pasta 1)

Thanks a lot

CodePudding user response:

for ZIP:

unzip -l archive.zip

for RAR:

unrar -l archive.rar

CodePudding user response:

You can unzip zip files in R using the base R function unzip. I am not sure if there is a similar solution for RAR files. Once unzipped, you can use the base R function list.files() to list the names of the files and folders in any directory on your computer, e.g. list.files(path="mypath").

  • Related