Renaming a folder with the name of folder within.

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

Moderator: Mr_Noodle

Hi everyone,

I download lesson files from a particular site often and they download with the same name "project_files.zip". I set up a rule to move those files to an external drive and unarchive them.

What I would like to do is to rename those "project_files" with the name of the folder that is contained within this project_files folder. There is only one folder within each of these project_files folders that describes the lesson I am working on.

Any idea how this can be done?

Thanks in advance!
gmf1111
 
Posts: 3
Joined: Thu Sep 26, 2013 8:14 am

I assume you are referring the folder that is contained within the zip file? In that case, you'll have to use a script to pull that off.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Why rename the top level folder? Why not just move the sub folder, which is named what you want and delete the pop level folder instead? It would be much simpler.

Bryan
Bryan
 
Posts: 25
Joined: Wed Jan 11, 2012 4:34 pm
Location: Maryland

Do you have any suggestions of how to set that rule up? I have been trying to do what you suggested with no success.

Thanks again.
gmf1111
 
Posts: 3
Joined: Thu Sep 26, 2013 8:14 am

Looks like the following worked out for me:

I created a rule that looks for the project_files.zip documents that are downloaded to the Downloads folder. Hazel moves those files to an external drive, extracts them, then deletes the zip file.

Next, I created a rule that looks for the subfolder in the folder named project_files and moves that folder up one directory. The last rule that I made was a rule that looked for empty folders (Kind=folder, size=0kb) which deletes the empty folder generically named project_files. I had to move this rule to the top of the list otherwise the empty folders were not being deleted.

Thanks all for your help. If you have a more efficient way of accomplishing this, I would love to hear your idea.
gmf1111
 
Posts: 3
Joined: Thu Sep 26, 2013 8:14 am


Return to Support