Count files and rename based on result

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

Moderator: Mr_Noodle

Count files and rename based on result Thu Aug 13, 2020 7:38 pm • by laurie_lewis
HI,

I am trying to compare two directories based on the number of m4a files that the directories contain.

What I would like to do is for Hazel to go to each folder and count the number of m4a files the folder contains and then rename the folder based on current-name + no-of-m4a-files.

I want it to go through the folder structure doing this to all folders. There are a massive number of files and some have been renamed hence the count.

Any ideas on how this could be done.

I have been using to count the numbers but I don't think I can hand that result back to hazel as a variable.

Code: Select all
find /volume1/Audio | fgrep -c '.m4a'


any help appreciated.

Laurie
laurie_lewis
 
Posts: 21
Joined: Thu Mar 14, 2013 11:53 pm

Re: Count files and rename based on result Fri Aug 14, 2020 9:12 am • by Mr_Noodle
You can't with a shell script, but you can with an AppleScript. You can have an AppleScript call the shellscript but you'd need to have the script parse the output so that it can send it back to Hazel. Check the chapter on AppleScript in the manual on how to use output attributes.
Mr_Noodle
Site Admin
 
Posts: 11226
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support