Jump to content
sim871

[SOLVED] Rename file using its parent directory name???

Recommended Posts

Hi All,

Just found out about the app Alfred while searching automation options.
I am hoping the community can shed some light on whether Alfred can help me or not and if yes, give me a steer in the right direction.

 

What I would like to do is:
1-Rename an mp3 file, preserving its extension, using its parent, sub-directory name.
2-Move the file to the root directory and delete the original parent directory.

 

For example, change this:
Songs (Root directory)
    Good song (sub-directory)
        asdfgh.mp3 (file)
    Really good song (sub-directory)
        zxczvb.mp3 (file)

 

To this:
Songs (Root directory)
    Good song.mp3 (renamed & moved file)
    Really good song.mp3 (renamed & moved file)
    

Many thanks,
Sim871

Share this post


Link to post

Welcome @sim871,

 

Yes, that is quite possible, though not without coding. Also, you need to buy Alfred’s PowerPack. If you do so, I can make the workflow for you. It’ll work like this:

  1. You select the file.

  2. Press a keyword. A menu will appear.

  3. You pick the relevant action.

  4. Done.

Share this post


Link to post

Hi Vitor,

Thanks for the speedy reply. I purchased the power pack. Grateful for any help!

For clarity, I was hoping to point Alfred to the Songs (Root directory) and have it run the script/macro against all of the sub-folders in the the Songs (Root directory).

Is this possible?

 

Songs (Root directory)
    Good song (sub-directory)
        asdfgh.mp3 (file)
    Really good song (sub-directory)
        zxczvb.mp3 (file)

 

To this:
Songs (Root directory)
    Good song.mp3 (renamed & moved file)
    Really good song.mp3 (renamed & moved file)

Share this post


Link to post

This should work.

 

It only works on .mp3 files, but it does work recursively (it moves everything to the top directory).

 

Do note as a warning that since its operations are destructive (it renames the file and deletes the directory) you should back up your data before running the Workflow, just in case. For example, if a directory has two .mp3 files, since both will be moved to the top directory with the same name, one of them would be lost.

 

To run this, select your Songs directory (can be any name) and run the Rename Songs File Action.

Share this post


Link to post
17 hours ago, sim871 said:

All I can say is MAGIC! And thank you.

Works amazing.

 

You’re welcome. I’m glad.

 

17 hours ago, sim871 said:

What language is the script written in?

 

Ruby, but any general purpose language would’ve worked.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...