Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

RazorBackXX

macrumors member
Original poster
Oct 1, 2023
62
8
Lylat System
I have a M1 Mac running Sonoma. I use a program called Downie to download music videos off my YouTube playlist, when I do this it creates a number sequence that can go up to 100. how do I format it to remove it? is there a shorthand way of doing it. everyday I batch rename photos & videos. & if for example all the photos start with the word photo then I would format them by typing in photo then I would press space on the replace. there has to be a easier way to batch format the numbers instead of manually renaming each & every single of of the videos. if anyone has an app or any suggestion at all please let me know. thank y'all.


Screenshot 2024-01-17 at 11.36.59 AM.png
 
Not sure I totally understand. Are the extra numbers always at the beginning?

I really like Name Mangler (https://manytricks.com/namemangler/) but it's $19. Does lots of renaming things, but to remove the first characters see screenshot below. The left column shows the current filenames, the right column what the resulting filenames will be after you click the "Rename 3 Files" button. The interface is easy, and I really like that you can see the new filename before you execute the change.
 

Attachments

  • Screen Shot 2024-01-17 at 6.17.52 PM.png
    Screen Shot 2024-01-17 at 6.17.52 PM.png
    373.8 KB · Views: 58
  • Like
Reactions: RazorBackXX
You can achieve this by using a script:

Python:
import re
import os

# set directory
os.chdir("/Users/yourname/Downloads")

# list files if file name match regex
pattern = r"^\d{3} - .*"
matched_files = []
for filename in os.listdir():
    if re.match(pattern, filename):
        matched_files.append(filename)

# remove the number, space, dash and the space (001 - ) from the file name
for filename in matched_files:
    new_filename = re.sub(r"^\d{3} - ", "", filename)
    os.rename(filename, new_filename)

  1. Back up your entire folder just in case.
  2. Ensure the file names after renaming does not conflict - you can't have 2 files with the same name in a folder
  3. Copy and paste the code above to your Text Edit app
  4. In the menubar, select Format - Make Plain Text, skip this step if the menu says "Make Rich Text"
  5. In the 5th line of code, change the path to the folder of your videos
  6. Save the code, using UTF-8, using the filename "rename.py"
  7. Open the Terminal app, type python3, and type a space
  8. From Finder, drag the rename.py file to your Terminal window
  9. In your Terminal window, hit Enter
 
  • Like
Reactions: RazorBackXX
Not sure I totally understand. Are the extra numbers always at the beginning?

I really like Name Mangler (https://manytricks.com/namemangler/) but it's $19. Does lots of renaming things, but to remove the first characters see screenshot below. The left column shows the current filenames, the right column what the resulting filenames will be after you click the "Rename 3 Files" button. The interface is easy, and I really like that you can see the new filename before you execute the change.
Brian your amazing brother that was absolutely the app I needed.
 
  • Like
Reactions: Brian33
You can achieve this by using a script:

Python:
import re
import os

# set directory
os.chdir("/Users/yourname/Downloads")

# list files if file name match regex
pattern = r"^\d{3} - .*"
matched_files = []
for filename in os.listdir():
    if re.match(pattern, filename):
        matched_files.append(filename)

# remove the number, space, dash and the space (001 - ) from the file name
for filename in matched_files:
    new_filename = re.sub(r"^\d{3} - ", "", filename)
    os.rename(filename, new_filename)

  1. Back up your entire folder just in case.
  2. Ensure the file names after renaming does not conflict - you can't have 2 files with the same name in a folder
  3. Copy and paste the code above to your Text Edit app
  4. In the menubar, select Format - Make Plain Text, skip this step if the menu says "Make Rich Text"
  5. In the 5th line of code, change the path to the folder of your videos
  6. Save the code, using UTF-8, using the filename "rename.py"
  7. Open the Terminal app, type python3, and type a space
  8. From Finder, drag the rename.py file to your Terminal window
  9. In your Terminal window, hit Enter
Genius my friend
 
You can achieve this by using a script:

Python:
import re
import os

# set directory
os.chdir("/Users/yourname/Downloads")

# list files if file name match regex
pattern = r"^\d{3} - .*"
matched_files = []
for filename in os.listdir():
    if re.match(pattern, filename):
        matched_files.append(filename)

# remove the number, space, dash and the space (001 - ) from the file name
for filename in matched_files:
    new_filename = re.sub(r"^\d{3} - ", "", filename)
    os.rename(filename, new_filename)

  1. Back up your entire folder just in case.
  2. Ensure the file names after renaming does not conflict - you can't have 2 files with the same name in a folder
  3. Copy and paste the code above to your Text Edit app
  4. In the menubar, select Format - Make Plain Text, skip this step if the menu says "Make Rich Text"
  5. In the 5th line of code, change the path to the folder of your videos
  6. Save the code, using UTF-8, using the filename "rename.py"
  7. Open the Terminal app, type python3, and type a space
  8. From Finder, drag the rename.py file to your Terminal window
  9. In your Terminal window, hit Enter
ok bro ive tried this over & over & I can't seem to get it to work. when you say 5th line of code. I assume I highlight the whole thing including python. weird bro, of some reason when I reply to your message it says Code=Python but on my end I sent a screenshot & it just says python. here are the screenshots & the issues I keep getting. im going to try it with the code=python to see if it makes a difference. everything is in my downloads folder to make it easier.
 

Attachments

  • python on replay.png
    python on replay.png
    3.4 KB · Views: 53
  • python in chat.png
    python in chat.png
    23.2 KB · Views: 47
  • how my textedit looks.png
    how my textedit looks.png
    31.8 KB · Views: 56
  • downloads folder.png
    downloads folder.png
    91.2 KB · Views: 51
  • terminal error.png
    terminal error.png
    121.8 KB · Views: 50
First, the script should not have "Python:" in it. That's not part of the script. Also, the text doesn't match exactly what the original post was. In python, white space and line breaks matter. Your file doesn't match what's on the web page.
 
ok bro ive tried this over & over & I can't seem to get it to work. when you say 5th line of code. I assume I highlight the whole thing including python. weird bro, of some reason when I reply to your message it says Code=Python but on my end I sent a screenshot & it just says python. here are the screenshots & the issues I keep getting. im going to try it with the code=python to see if it makes a difference. everything is in my downloads folder to make it easier.
I made a more interactive version. Download and unzip it you'll get the rename.py file.

Then, just do the step 1, 2, 7, 8, 9 in my previous reply, and follow the instructions in the Terminal window.
 

Attachments

  • rename.py.zip
    565 bytes · Views: 71
I’m not understanding exactly what format you’re seeking but Finder does have a tool:


There’s also:

 
I use the rename tool every day but it does not have a feature that I need. I need to remove the 001-100 & I can't batch do that with finder. thank you for the app my friend.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.