You can also watch this video at YouTube (but with ads).
Complex Batch File Renaming With Shortcuts and Regular Expressions
Comments: 13 Responses to “Complex Batch File Renaming With Shortcuts and Regular Expressions”
Comments Closed.
You can also watch this video at YouTube (but with ads).
I wonder if this Shortcut could be used to batch create PDFs from text files by "renaming" the extension to "pdf." I figured creating PDFs is a good way to backup documents created in Pages, Word and Text Edit.
Thanks,
Jose Vasquez
Jose: You can't create PDFs by just renaming document files. You have to open them up in the app you used to create them and export PDF files. PDF files can't be edited, really, so if your goal is to back up your files, just create copies of them. Or, just use Time Machine to back everything up (I assume you already are, right???)
Hi Gary, this video shows how to switch existing words of a file name around, but is there a way to shorten/delete existing words? For example, rename the files to only the first word (e.g. the existing file “Alpha Beta Gamma” would become just “Alpha”). I have many files with long names that I want to shorten. Also, does this video lesson work for iPhone? I tried using your exact shortcut but my phone thinks I have a file literally named “^(\w*)\s(w*)\s(w*)$” and want to change it “$3 $2 $1”
Jules: Yes. You can do that. So instead of $3 $2 $1 you would just want to use $1 as the result. It should work on the iPhone too, yes.
Thanks Gary. My bad, yes, it does work on iPhone (I had copied the expression incorrectly). Using $1 as the result works too, thanks for the tip.
Is there an expression that can replace every word/character? (My files have more than three words). Using your shortcut, I tried changing ^(\w*)\s(\w*)\s(\w*)$ to the variable “text” (resulting from “get text”) hoping that $1 would replace all of the text to just the first word but it didn’t work.
Jules: You can do almost anything with regular expressions. That's a big topic. From your description I can't tell what you want though. Try searching online for regex or regular expressions to learn more.
Gary, thanks for pointing to me regex (I didn’t know about it). I had a lot to learn and understand, but was able to accomplish my task. Thank you!
Hi Gary, Do you have a simple shortcut for batch renaming files in the iOS Files app? Like adding text before, after or replace. The rename tool on the mac is not available on iOS. Thanks
Guillaume: Can you just do it on your Mac then? If the files are in iCloud Drive, which is usually the case for the iPhone, then just use the batch rename tool on your Mac to rename them. If not, doing it with Shortcuts isn't ideal but could work. It is just a matter of learning to use that action.
Hi Gary, thx u for tutorial - trying to batch rename files (pdf) receipts based on contents date, name, product, currency amount, using shortcuts Quick Look, tried Automator with script -to difficult.
Alexander: Not sure what to suggest then. Difficult tasks require some amount of work. What's your reason for needing to rename the files when you can search for the contents inside the files with Spotlight?
Hi Gary,
Could you make a video or share a shortcut similar to the Automator's Quick Action “Rename Finder Items”? I've been using it for decades and now I want to convert it to Shortcuts, but can't export it there. In Automator's Quick Action “Rename Finder Items” user can choose how to change file names by choosing menu, and that's very useful.
Thank you!
Agha: What is it you are trying to do? Can it be done with the regular Finder rename? If not, what is it you need?