How to delete a file only if the new file is a movie/audio?

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

I’m trying to create automation on a folder. The goal is automate an FFMPEG script that takes audio.wav and video.mov and turns them into one file.

I want to drag a video or audio file into a folder and then automatically it will rename it to audio.wav or video.mov depending on the file type. If audio.wav or video.mov already exists, I want it to be deleted/overwritten.

This is a stumbling block for me because the way I have it set up, it always deletes audio.wav even if only a video file has been added. And the FFMPEG script needs both

How do I make it check if an audio file has been added and make it keep the video file. And vice versa?
ranges_brevets
 
Posts: 3
Joined: Tue Feb 04, 2025 7:32 pm

You can try using a nested condition. For example:
Code: Select all
   if (all) are met
       Full name is video.mov
       If (all) are met for (any file or folder in the same folder)
           Full name is audio.wav

That matches a video.mov file if an audio.wav file also exists in the same folder. You'll have to tweak it for your specific needs.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Mr_Noodle wrote:You can try using a nested condition. For example:
Code: Select all
   if (all) are met
       Full name is video.mov
       If (all) are met for (any file or folder in the same folder)
           Full name is audio.wav

That matches a video.mov file if an audio.wav file also exists in the same folder. You'll have to tweak it for your specific needs.


Thanks! That helps

Now I'm wondering how to make it work if I copy multiple files at the same time. How can I make it process one file, finish it, then move on to the next one?
ranges_brevets
 
Posts: 3
Joined: Tue Feb 04, 2025 7:32 pm

All rules only operate on a file at a time.
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Open Discussion