Search for & act on files within zips?

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

Search for & act on files within zips? Thu Oct 20, 2016 3:39 pm • by MacOCD
Is it possible for search for files of a certain type within zip files and perform an action on them still keeping them within the zip?

I want to perform audio normalisation on MP3 files held within karaoke .zip files.

Thanks,
Mark.
MacOCD
 
Posts: 44
Joined: Fri Sep 26, 2014 11:02 am

Re: Search for & act on files within zips? Fri Oct 21, 2016 5:19 am • by MacOCD
To clarify...

I run a Karaoke and my online purchased music files come as a zip, inside the zip are 2 files, the .mp3 (audio) and the .cdg (graphic). These .zip files are stored for use by karaoke software and are temporarily extracted when played, but the stored version is still the .zip

Some songs are louder than others so I want to run an audio normaliser app called mp3gain over the .mp3 file stored within the many 1000 of individual .zip tracks.

Can Hazel search within .zip files to find .mp3 files to act on?

Thanks,
Mark.
MacOCD
 
Posts: 44
Joined: Fri Sep 26, 2014 11:02 am

Re: Search for & act on files within zips? Fri Oct 21, 2016 10:33 am • by Mr_Noodle
No way to do that unless you use some special script. The only option otherwise would be to unpack the archive then match on the file.
Mr_Noodle
Site Admin
 
Posts: 11746
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Search for & act on files within zips? Fri Jan 10, 2025 9:28 am • by HazelEyes
Mr_Noodle wrote:No way to do that unless you use some special script. The only option otherwise would be to unpack the archive then match on the file.


I'm wanting to do the same thing. I believe I'm pretty close, but maybe you can help me.

I am saving an "export.zip" to my downloads folder that I want to look inside (not extract) and then move the zip file elsewhere. The zip file is an Apple Health export file. So inside the zip there is one folder that is "apple_health_export" and inside that there is a file "export.xml". I'm using the unzip command to see if that file exists and then outputting that file to screen.

Code: Select all
unzip -p $1 apple_health_export/export.xml | less


I'm using the Pass shell script condition, however no matter what the zip file is (The actual Health zip or some other zip named export.zip), it always matches the rule. So it's always exiting with status 0, but not sure why if the file I'm searching for doesn't exist. I'm sure I'm missing something here.
HazelEyes
 
Posts: 6
Joined: Thu May 27, 2021 9:36 am

Re: Search for & act on files within zips? Fri Jan 10, 2025 9:31 am • by Mr_Noodle
The shell script return value only indicates whether it ran successfully or not and has nothing to do with anything you output.

You need to do a comparison against the output and use the exit command with the appropriate return code.
Mr_Noodle
Site Admin
 
Posts: 11746
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Search for & act on files within zips? Fri Jan 10, 2025 1:01 pm • by HazelEyes
Mr_Noodle wrote:The shell script return value only indicates whether it ran successfully or not and has nothing to do with anything you output.

You need to do a comparison against the output and use the exit command with the appropriate return code.


Not sure if this is the best way, but it works! Thanks!

Code: Select all
unzip -l $1 | grep -q apple_health_export && echo $?
HazelEyes
 
Posts: 6
Joined: Thu May 27, 2021 9:36 am


Return to Support