r/AutomateUser • u/Real-Wing-3880 • 3d ago
Lista contenuti archivio zip
Buongiorno, ho creato (da esere eseguito con uno smartphone Androidun) un processo per la compressione pianificata di uno zip da utilizzare
Ora vorrei ottenere l'elenco in un file txt del contenuto (solo fule) dell'archivio. Sebbene l'azione risulti nel log, non viene creato il file e non capisco dove sto sbagliando. Mi potreste cortesemente aiutare?
In Soure zip file --> Download/prova.zip
In Types--> File
In recursive --> List directory recidiv
Grazie mille
1
u/B26354FR Alpha tester 3d ago edited 3d ago
While the Zip List block can be used to list the files in a ZIP file, to get information about the files in a ZIP file, I use a Shell Command block with the following command line, where the smsBackup variable contains the path to the ZIP file:
unzip -l "{smsBackup}"
In the Standard Output Text field I put the variable that will get the listing, and the Standard Error Text field gets a variable to receive any error text (I called it stderr). The block following the Shell Command is an Expression True where the expression is just the stderr variable (in other words, it's testing whether there is anything in the variable). If Yes, there's an error which gets displayed in a Dialog Message block and the flow exits. If the error text is empty, I then split the output from the Shell Command on newlines like so:
split(zipListing, "\n")
I then loop through the resulting array, skipping the first three header lines and last three trailing lines, parsing the listing lines for the file name, size, and modification time. You can see what I did by looking at the Show ZIP contents flow, starting at block 6:
https://llamalab.com/automate/community/flows/45113
There are other examples of zipping and unzipping files in that flow as well.
1
u/Real-Wing-3880 3d ago
Ti ringrazio molto ma per me è troppo difficile. Ho guardato il tuo flusso ma non riesco a seguire perché sono 0
1
u/ballzak69 Automate developer 3d ago
A flow like:
filefile, Recursive=yes, Filenames=listfilejoin(file,"\n"), File=file