playing with files

Not the best description, i know, but i need some help here :slight_smile:

I have a script that pulls out attachments, unzips gz files, which is fine, but it also pulls out regular zip archives. I figured out how to unzip those, my problem is the contents of the zip. it contains 4 files, all with different names (below)

spotify-revshare-for-downloads-for-venzodigital-201211.txt
spotify-revshare-for-venzodigital-201211.txt
spotify-track-for-downloads-for-venzodigital-201211.txt
spotify-track-for-venzodigital-201211.txt

The only file i have to import is the last one (also happens to be the largest in size).

Is there some way that i can just extract that one file and then delete the entire archive? I have a feeling i’ll have to extract all the files into a folder, then check the size on each one, then delete the ones i don’t want, then move that one file back into another folder for to be imported.

I think this is pretty accurate. I’m no sysadmin but I have never seen a way to extract a file based on it’s size.

yea i was just hoping there was a simpler way of doing it. oh well, time to add another 50 or so lines of code :frowning:

This could be useful, if you could check the uncompressed size of all files in a zip you could then extract only the largest file.

-l --list

For each compressed file, list the following fields:

compressed size: size of the compressed file
uncompressed size: size of the uncompressed file
ratio: compression ratio (0.0% if unknown)
uncompressed_name: name of the uncompressed file

That’s if you were using a shell script, it would just display it on the screen. I’ve got a good idea on how to do it with php.

I was thinking you could use shell_exec() which would send the gzip -l results to a string that you could parse to find the largest file.

Php has built in functions for zip files and I havent had any luck in the past in using shell shell functions in a cronjob… Im going be working on it tonight. Ill post what I have if I get it figured out.

Sponsor our Newsletter | Privacy Policy | Terms of Service