Если вы просто пытаетесь вырезать весь текст до того, как в имени файла будет найдена первая цифра, то что-то вроде этих строк с относительно простым регулярным выражением должно работать в python:
import os
import re
# replace with the path to your file:
path = 'test/'
for filename in os.listdir(path):
os.rename(os.path.join(path, filename),
os.path.join(path, re.search('\d.*',filename).group()))
Мы можем создатьтестовый файл просто для удовольствия, чтобы увидеть, что он работает:
import os
import re
# list out all the filenames to put into our test directory
l=['image-w-inch-bob-bob-bob-bob-8820-AV1.jpg',
'image-w-inch-bob-bob-bob-bob-8820-AV2.jpg',
'image-w-inch-bob-bob-bob-bob-8820-AV3.jpg',
'image-w-inch-bob-bob-bob-bob-8820-AV4.jpg',
'image-w-inch-bob-bob-bob-bob-8820-AV5.jpg',
'image-w-inch-bob-bob-bob-bob-8820-AV6.jpg']
# Create Directory
os.mkdir('test')
# add in all the files
for f in l:
open(f'test/{f}','a').close()
# All the files are there
>>> os.listdir('test')
['image-w-inch-bob-bob-bob-bob-8820-AV5.jpg', 'image-w-inch-bob-bob-bob-bob-8820-AV4.jpg', 'image-w-inch-bob-bob-bob-bob-8820-AV6.jpg', 'image-w-inch-bob-bob-bob-bob-8820-AV3.jpg', 'image-w-inch-bob-bob-bob-bob-8820-AV2.jpg', 'image-w-inch-bob-bob-bob-bob-8820-AV1.jpg']
# rename with the loop provided above:
path = 'test/'
for filename in os.listdir(path):
os.rename(os.path.join(path, filename),
os.path.join(path, re.search('\d.*',filename).group()))
# all the filenames have changed
>>> os.listdir('test')
['8820-AV1.jpg', '8820-AV3.jpg', '8820-AV2.jpg', '8820-AV6.jpg', '8820-AV5.jpg', '8820-AV4.jpg']