1

I've searched high and low, but haven't come up with a viable solution. I want to enable sorting of these files by the sequence number in the file name, however the sequence is appended to the file name. If it was prepended I could accomplish my goal.

Currently files in finder appear as:

  • this is a great story_100.mp4
  • another great story of another time_103.mp4
  • yet another fantastic story_101.mp4
  • our last story_102.mp4

Trying to get to:

  • 100_this is a great story.mp4
  • 101_yet another fantastic story.mp4
  • 102_our last story.mp4
  • 103_another great story of another time.mp4

How can I accomplish this on a Mac? I've tried applications Renamer and NameChanger, the latter which supports regex, but I'm stuck. Lord this is frustrating...please help and many thanks to you in advance for the dear soul to lend the solution!

1

I'm not familiar with either of the programs you've tried, but here's how to do it in A Better Finder Rename ($20), and I expect at least one of yours can do it in a very similar manner. See below the screenshot for instructions and an explanation.

screenshot

First, I chose ABFR's "Re-arrange using regular expressions" feature. This will probably be named something similar in other programs. This requires a regular expression to match with, followed by a substitution pattern to create the new filename.

(.*)_(\d{3})\.mp4
  • The first capture group (.*) simply matches any number * of any character . necessary to make the filename match.
  • This is followed by a literal underscore, which in your case delimits the border between the filename and number.
  • Then, the second capture group (\d{3}) matches exactly three {3} digits \d. If some of the files have more or fewer than three digits, say a number between n and x, you would change it to (\d{n,x}).
  • Finally, the extension is matched with an escaped period \. and mp4. If your files have different extensions, you should change this to \.(\w{3}) — just like the number, but with characters \w instead of digits.

Then, we use those capture groups to make the new filename. The syntax for this part may vary more between programs.

$2_$1.mp4

This is perhaps more straightforward: our second set of parentheses surrounded the number, so we put that first with $2, followed by an underscore, the filename $1, and the extension .mp4. (If you used \.(\w{3}) earlier, write $2_$1.$3 instead.)

If you'd like practice and help with writing regular expressions, I recommend the website RegExr, which provides live syntax highlighting and tooltips.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .