Move Certain File to Trash

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

Moderator: Mr_Noodle

Move Certain File to Trash Fri Mar 22, 2024 7:11 pm • by klind
I have over 3K directories containing videos. I am in the process of reducing the size of many of these videos by converting them from .MKV files to .MP4 files. All is going well until I want to get Hazel to delete the duplicate .MKV files. How can I search for any given subdirectory that contains two files with the same name and then move only the .MKV file to trash. I've tried coding the .MP4 file with a tag and I can find it OK, but I need to move the opposite file. Is this possible?
klind
 
Posts: 33
Joined: Mon Jan 30, 2017 7:02 pm

Re: Move Certain File to Trash Mon Mar 25, 2024 9:31 am • by Mr_Noodle
First off, please do not post Hazel issues to the Forum/Site Discussion section. That is for issues related to the website.

Look up nested conditions in the manual. You can set up something like:
Code: Select all
If (all) are met
    Extension is mkv
    If (all) are met for (any file in the same folder)
        Name matches (name)
        Extension is mp4


That will match an mkv file is there is an mp4 file with the same name in the same folder. You may need to tweak that for your specific case but that should give you a starting point.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Move Certain File to Trash Mon Mar 25, 2024 5:09 pm • by klind
Thank you for the response. I hope you moved this post appropriately. I will try to do better in the future.
klind
 
Posts: 33
Joined: Mon Jan 30, 2017 7:02 pm

Re: Move Certain File to Trash Mon Mar 25, 2024 7:06 pm • by klind
Mr Noodle, sir, your much appreciated response has left me with an additional question.

Code: Select all
If (all) are met
    Extension is mkv
    If (all) are met for (any file in the same folder)
        Name matches (name)
        Extension is mp4


How can I enter the (name) to match as I am running this through many sub-directories with many files of a different name. I see I could use matches (anything), and that would probably work, but it seems to me that using (anything) could be dangerous. Also you didn't suggest (anything), you suggested (name). How do I get the name of the file that is found in the first part where extension is mkv?
klind
 
Posts: 33
Joined: Mon Jan 30, 2017 7:02 pm

Re: Move Certain File to Trash Tue Mar 26, 2024 9:10 am • by Mr_Noodle
(name) is the built-in Name attribute. It represents the name of the file currently being matched.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support

cron