Page 1 of 1

Rename all files in subfolder with rootfolder_name_...

PostPosted: Mon Apr 23, 2018 9:21 am
by Black2Back
Hi there,
my name is Erik and I'm still a newbie to hazel, though I use it for some month. So most of the initial processes are quite clear to me.
But I have a special challenge and hope you can help me.

My monitored folder for the hazelrule is located in my homefolder and called “convert”.
It’s empty and for renaming purpose.
I will copy each of my customer-folder separately to the “convert” folder and let hazel do the rest.
When hazel has finished I move it back to the server (Just don't want to operate on live system...). That's my plan :)

My folder-hierarchy for every customer is the same:

/customer1:
/customer1/eol
/customer1/documentation
/customer1/internet-contracts


/customer2:
/customer2/eol
/customer2/documentation
/customer2/internet-contracts


All root- and subfolders contain .txt files that have to be:
*converted to docx (done :) )
*renamed. All files (the names of the files are also the same in each customer folder) from e.g. firewall.docx to customer1_firewall.docx. Just the customer name as a prefix_

I managed to get the name from the customer folder (as monitored folder path) into the filename, replaced the “/” with "_", but as expected the filename contains the whole subfolder structure, in case of /customer1/documentation/firewall.docx the filename in the end is “customer1_documentation_firewall.docx”.

But I want to have only the customers root folder name, no matter in which subfolder the file lies.
And – btw – I would like to minimize using shell scripts, it’s not really my world.
If not possible without shell, maybe you have a good template… My colleague should be able to (at least) read it, evtly customize it. (I know - with shell I could read the foldername, print it into a variable and rename the files.)

Thx for your help!
erik

btw: High Sierra with all updates and hazel 4.2.4

Re: Rename all files in subfolder with rootfolder_name_...

PostPosted: Mon Apr 23, 2018 12:21 pm
by Mr_Noodle
I've already replied via email. In the future, please limit yourself to either posting in the forums or emailing, otherwise it results in extra work for both sides.

Re: Rename all files in subfolder with rootfolder_name_...

PostPosted: Mon Apr 23, 2018 1:26 pm
by Black2Back
Mr_Noodle wrote:I've already replied via email. In the future, please limit yourself to either posting in the forums or emailing, otherwise it results in extra work for both sides.


ok, I didn't know that forum and support are by the same guys (or at least one) ;-)

If it's ok, I'd prefer to continue here, maybe it will be help for other users, too...

I'll send you the exported rules tomorrow when I'm back at work.

br, erik