Jump to content

RenameAction — Renames a directory or file (preserving the extension)

Recommended Posts

  • 2 weeks later...
  • 3 months later...
1 hour ago, pontus said:

Great workflow, very useful, thanks!


Thank you. Glad you find it useful.


1 hour ago, pontus said:

I want to trigger it externally (as described here) but then the external trigger must be placed before the parsing script. 


To trigger it externally, you’ll need to add an External Trigger that connects to the top Run Script.


1 hour ago, pontus said:

Any specific reason for the placement of the trigger? 


Yes. Admittedly that External Trigger is more like an Internal Trigger. It’s not meant to ever be called from outside the Workflow. I’m using it as a trick to pass a bunch of variables around without having to resort to temporary files.

Link to post
56 minutes ago, pontus said:

(Shouldn't every workflow have an external trigger hehe).


Issue is some Workflows have so many possible inputs, adding an External Trigger for all can become quite a mess. So I typically only add the ones I need or that I think will be particularly useful. If someone else needs another, its easy enough to add and I can even help the user make it custom.


1 hour ago, pontus said:

For me it works fine without the "trick", is it for older versions of alfred?


You’d need to show me your version working without for me to say for sure if I could use your approach.

Link to post
  • 2 weeks later...
  • 1 month later...

This is a very helpful workflow - it functions well and I also edited it to post a notification that says "Renamed from {var:oldfilename} to {var:newfilename}".

However I did notice that if you rename file A the name of an existing file B of the same type in the same directory it overwrites file B (and I have no idea where the old one goes - not in the trash :). Hopefully and presumably something the filesystem can manage). Similarly renaming folder A to the name of folder B in the same directory will move folder A into folder B.


Ideally both of these scenarios would report an error and not follow through with the operation, or utilize similar behavior as Finder, by addending "1" "2" "3" etc. to the new file name (or if that's not possible perhaps addending "copy from {time}" to the filename using the {time} dynamic placeholder as a unique identifier)


Let me if I'm missing something, but for now I won't use this since I may accidentally delete files with it.



Link to post
8 hours ago, deanishe said:

Yeah, that sounds like the default behaviour of the mv command.


It is.


10 hours ago, pacifist said:

similar behavior as Finder, by addending "1" "2" "3" etc. to the new file name


That’s for copying files. Finder doesn’t have such a scheme for renaming — it aborts and tells you to pick a different name.


10 hours ago, pacifist said:

(or if that's not possible perhaps addending "copy from {time}" to the filename using the {time} dynamic placeholder as a unique identifier)


Made it into something like that. If the path already exists, it’ll append the date and time to the name (and in the extremely unlikely event a file name with that exact same date string already existed, it’ll try again until it’s sure the name is unique.

Link to post


Prevent overwriting files.


Also updated to the latest version of OneUpdater (including lowering the update check frequency to 4 days).

To update, download the latest version (same URL) or wait a few days and it’ll prompt you to on next usage, since it uses OneUpdater.

Link to post
  • 7 months later...
  • 1 year later...

This is great, thank you so much!


One question, I am trying to augment this to duplicate a file first before renaming it. I am able to duplicate the file, but I can't figure out how to rename the duplicated file, it always renames the original file? Is there a simple one to do duplicate the file first and rename the duplicate?


thanks so much!


Update: I was able to find a work around by creating a hotkey for this workflow, and then creating a separate workflow that executes a key combo to duplicate a file, then another key combo for this workflows hotkey. Whew. Bit of a round about, but it works! I was also able to make a tiny edit to the bash script to remove the 'copy' in the duplicated file name as well. Thanks again for the great workflow!

Edited by proxemics
Link to post
  • 1 month later...

Join the conversation

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

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...