Lowercasing File Extensions

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

Moderator: Mr_Noodle

Lowercasing File Extensions Fri May 29, 2009 5:08 pm • by Brooksie
Hi guys,

Here's my scenario: I have a digital camera, as I'm sure most other people do too. When I transfer the pictures from my camera to my computer, the pictures all have uppercase extensions (.JPG, .AVI, etc). I would like to use Hazel to automatically identify pictures with a JPG extension, and rename the extension to jpg.

I am able to set up a rule in Hazel to automatically lowercase an image's extension, but I only want to perform this lowercasing if the extension is actually uppercase. Unfortunately, the matching rules in Hazel are case insensitive.

Is there anyway that I can accomplish my goal using Hazel?
Brooksie
 
Posts: 3
Joined: Fri May 29, 2009 5:01 pm

Re: Lowercasing File Extensions Fri May 29, 2009 5:58 pm • by Mr_Noodle
I can't think of anything off the top of my head. If you don't mind me asking, though, why do you want to do this? Are you trying to preserve mixed case jpg extensions (i.e. Jpg, jPG)? It's hardly any extra work to lowercase something that is already lowercase.
Mr_Noodle
Site Admin
 
Posts: 11230
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Lowercasing File Extensions Fri May 29, 2009 6:36 pm • by Brooksie
Mr_Noodle wrote:I can't think of anything off the top of my head. If you don't mind me asking, though, why do you want to do this? Are you trying to preserve mixed case jpg extensions (i.e. Jpg, jPG)? It's hardly any extra work to lowercase something that is already lowercase.

There is one problem with lowercasing something that is already lowercase. Since I can't identify only uppercase extensions, Hazel just spins, constantly lowercasing every image over and over. It never stops. Resulting in constant high CPU usage, lowered battery life, excessive harddrive usage due to unnecessary modifications, and this updates the "date modified" field for the files (which causes my backup software to think the file has been modified and needs to be re-backed up).
Brooksie
 
Posts: 3
Joined: Fri May 29, 2009 5:01 pm

Re: Lowercasing File Extensions Sat May 30, 2009 10:30 am • by Mr_Noodle
If a file matches the same rule over and over, Hazel shouldn't execute the actions. If so, then something is going on. Is it possible files are oscillating between two different rules? Are these files on any sort of weird filesystem (network share, thumb drive)?

One thing to do is to check the logs by going to the "Info" tab and clicking "View Log". Feel free to send me anything interesting there.

As for the date modified, that's a fair point. I've already put in a patch (so it should be in the next version) such that if a rename will result in the same file name, it doesn't actually do the rename. Though, file renames affect the modification date of the containing folder, not the file itself. If you are observing the modification times of the files themselves being changed, then I suspect something else is going on.
Mr_Noodle
Site Admin
 
Posts: 11230
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Lowercasing File Extensions Sat May 30, 2009 1:49 pm • by Brooksie
Mr_Noodle wrote:If a file matches the same rule over and over, Hazel shouldn't execute the actions. If so, then something is going on. Is it possible files are oscillating between two different rules? Are these files on any sort of weird filesystem (network share, thumb drive)?

The files are all local to my Mac, so no weird filesystem. I guess there isn't a way for me to actually verify that Hazel is executing the actions multiple times. I made my assumption based on the fact that my CPU utilization would skyrocket (with Hazel using 70%+ CPU) for many minutes. I have a few thousand files being lowercased, and didn't think it would take that long to execute the actions a single time over all the files.

Mr_Noodle wrote:One thing to do is to check the logs by going to the "Info" tab and clicking "View Log". Feel free to send me anything interesting there.

I'll rerun the actions I have set up and look at the logs. I'll report back if there is anything interesting.

Mr_Noodle wrote:As for the date modified, that's a fair point. I've already put in a patch (so it should be in the next version) such that if a rename will result in the same file name, it doesn't actually do the rename. Though, file renames affect the modification date of the containing folder, not the file itself. If you are observing the modification times of the files themselves being changed, then I suspect something else is going on.

I'm not sure which modification time was being changed (the files or the folders). I can check to see.


Basically, would it be possible to add in a feature for the rules that allows a user to specify that they want their match to be case sensitive?
Right now my rule is basically to match:
"Extension" "is" "JPG" and do the following "Rename file" with pattern "name extension (lowercase)"
Could a dropdown be placed on the match "is" to select case (in)sensitivity?
Brooksie
 
Posts: 3
Joined: Fri May 29, 2009 5:01 pm

Re: Lowercasing File Extensions Sun May 31, 2009 12:29 pm • by Mr_Noodle
Next time you see Hazel using a lot of CPU, select it in Activity Monitor and do "View->Sample Process". Email me the output of that.

It may just be a case of having thousands of files. Hazel does have to scan all of them to check the rules if you keep them in place. You could try modifying your workflow to move the files somewhere else after Hazel has processed them.

The fix to "short-circuit" the rename action if the name isn't actually changing should get rid of any timestamps being updated in those cases. But again, renaming a file updates the containing folder's timestamp so if any single file is renamed in the folder, the whole folder's timestamp gets updated. If your backup solution keys off of that and backups the whole folder then that may account for added activity.

In any case, I think it would help to narrow down what is going on here. Send me a sample (as described above) and you can even send me your rules if you want me to analyze them.
Mr_Noodle
Site Admin
 
Posts: 11230
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Re: Lowercasing File Extensions Wed Jun 03, 2009 12:10 pm • by a_freyer
I would suggest putting the lowercasing rule in another folder, and once it is complete, send the file to your picture folder.

Perhaps you can add the rule to the desktop and then send lowercased files to the "photos" section.
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado


Return to Support

cron