Page 1 of 1

rename folder to (filename of an inclusive file)

PostPosted: Sat Aug 04, 2018 9:24 pm
by NoodleNewbie
Hi:

Will I need to work out an apple script to do this?

Rename folder to filename of one of the inclusive files less the last 8 characters. The file to use is identified by its extension.
The folder has 3 or 4 files.

BEFORE
Folder name = AAABB_
name of file within folder "AAABB_" = happy it worked out_AAABBzzzzyyyy.EXT

AFTER
Renamed folder name = happy it worked out_AAABB

Thankyou for the direction/guidance/

Re: rename folder to (filename of an inclusive file)

PostPosted: Mon Aug 06, 2018 10:10 am
by Mr_Noodle
I think you can do it with match patterns and a nested condition. Something like:
Code: Select all
   If (all) are met
      Folder name is <<whatever>>
      If (all) are met for (any of its sub-files)
         Name matches (• file name)(character)(character)(character)(character)(character)(character)(character)(character)
   Do
      Rename (• file name)

where (• file name) is a custom attribute which you create to match anything. The overall pattern will match everything but the last 8 characters.

You may need to tweak the above depending on the specifics of your case but that should give you a start.

Re: rename folder to (filename of an inclusive file)

PostPosted: Mon Aug 06, 2018 7:03 pm
by NoodleNewbie
Very nice thinking! Using a dummy variable(Hazel attribute, custom token) to hold the filename, so then can use it rename the folder. Thankyou Mr. Noodle.


here it is , just in case, it helps others.


Hazel Rule
1 Select file with the desired filename (e.g. extension = XXX) Rename Folder (this file is 1 of 4 files within the folder)
2 Rename folder using the desired filename
Image


where Filename is a Custom Token
Set Custom Token to Anything (...) as we can select the desired filename by the file unique extension
Image