Benzi Posted April 15, 2013 Share Posted April 15, 2013 (edited) Here is a workflow for bulk renaming files. You select some files either in Alfred using the File Navigator or the File Buffer and use the File Action called "Rename with BulkRename", or select the files in Finder and use the hotkey to trigger the workflow for the selected files. Once triggered, Alfred will display a preview option and a bunch of preset actions that you can select. The preview option will display the modifications that will be made for each preset action listed. Preview Here are a couple of snapshot portions of what you see when pressing the Shift key: Issues are highlighted so that you know if running a preset will work or not. Even if you run that preset, nothing will happen. Preset Actions There are 6 actions included as a sample, but you can easily create your own actions using the .list keyword. To create a new preset, type in .list <new name>. Delete a preset using Cmd+Enter Each preset is nothing but a collection of simple steps that help make the preset action possible. For e.g. when you select the Append Sequence Number preset, you will be shown the preset editor: What the above tell is that the Append Sequence Number preset is a collection of two steps: add text '_seq' at end add number from 0, at end There are added to the preset using any of the steps [+] listed. You can add any number of steps to a preset, even the same ones over and over. You can delete an added step using Cmd+Enter When you add a new step to a preset, or edit an existing step by selecting it, you will be shown the Step Node Editor as above. The above is the example for the "Number Sequence" step, and for this step you can control what the starting number is, where the number should be added, and the format (leading zeros to be added). Items with a arrow -> are variables that you can change by pressing the Tab key. To add the step, just select the first option, and that step will be added to the Preset that you were viewing before. Steps Steps are the building blocks of each preset, and currently BulkRename has the following: Find and replace: find text and replace with another, supports regex and plaintext, case sensitive and insensitive Add text: add some text at the beginning or end of the filename Add timestamp: add a timestamp at the beginning or end of the filename. Timestamp is one of current time, file created or modified time. YYYY,YY,MM,DD,hh,mm,ss can appear in the format string Convert case: switch the case of the filename to lower, upper, or title Strip text: remove x characters from the filename either at the start of end Number sequence: append a running number sequence, starting from a value that you can specify MP3 Tagger (beta): Extract MP3 tags from MP3 files Regex group extractor: Regex group pattern extractor Change Extension: Allows you to change the extension of a file Keywords The main keyword is .rename (but you would not have to type that in if you use the File Action or the Hotkey) The second one to manage all your presets is .list. .preset and .node are keywords used by the workflow directly, and there is usually no need for you to type those in directly. Download Download from here Notes This works with Python 2.7.2 last I checked Have a look at the included sample presets using the .list keyword to get a hang of how presets are made, and then create your custom ones Edited April 23, 2013 by Benzi derico, vdesabou, drking and 2 others 5 Link to comment
Benzi Posted April 17, 2013 Author Share Posted April 17, 2013 (edited) Included two new preset steps that you can use to create presets: MP3 Tagger (beta): Extract MP3 tags from MP3 files. Supported tags are #artist, #album, #title and #track Regex group extractor: Regex group pattern extractor. You can extract parts of the file name using regex and then use those groups in any way you want. e.g. if your file name is 'this is a test.txt' and you want to move the last word to the first, use the command: (.*) (.*)//$2 $1. The first group matches everything uptil the last space, and the second group matches the last word. The replacement $2 $1 means the last group should come first followed by a space and then the first group. Here are some examples you can download to your custom preset folder to try out: Last Word First MP3 Tagger Mark Files with Underscore Your custom presets are saved in the following location: ~/Library/Application Support/Alfred 2/Workflow Data/com.benzi.a2w.bulkrename/user_presets Download the latest version here. Edited April 17, 2013 by Benzi Link to comment
Benzi Posted April 23, 2013 Author Share Posted April 23, 2013 Added: Step to change the file extension Alleyoop support derico 1 Link to comment
jaspalx Posted May 19, 2014 Share Posted May 19, 2014 You sir are a genius Love the flexibility you've built in for adding steps. Link to comment
danielrasmuson Posted September 29, 2014 Share Posted September 29, 2014 Wanted to say thank you. This is really helpful. Link to comment
politicus Posted December 13, 2016 Share Posted December 13, 2016 (edited) Very helpful workflow, but when using in Alfred 3, I get this error when trying to edit the preset with the .node and the .preset keywords: Starting debug for 'Files Rename Bulk' [2016-12-13 11:23:46][STDERR: input.scriptfilter] 31:39: syntax error: A “"” can’t go after this identifier. (-2740) Edited December 13, 2016 by politicus Link to comment
Alberto Posted December 20, 2016 Share Posted December 20, 2016 i would like to prepend a custom text, for example: file.txt -> TEXT_file.txt There is a way to create a preset with an *input* option for user to insert the custom text and don't create a "specific" role? thank you Link to comment
willbraden Posted May 16, 2017 Share Posted May 16, 2017 Is there a working link for this somewhere? Link to comment
Benzi Posted May 17, 2017 Author Share Posted May 17, 2017 23 hours ago, willbraden said: Is there a working link for this somewhere? Not at the moment. This workflow is no longer maintained / available. (I might have another go at a enhanced version, later, if time permits...) Link to comment
willbraden Posted May 18, 2017 Share Posted May 18, 2017 Okay. Thank you for the reply, and the workflow. Good luck to you. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now