You can run this python script and it will change all the current file names, so core-js-46asfv will become core-js after just removing the last part after the dash.
import os
def rename_all_files(path):
names = os.listdir(path)
print(names)
for dir in names:
if "-" in dir:
new_name = dir.split("-")
print(new_name)
name = ""
for item in range(len(new_name)-1):
name += new_name[item]
if item < len(new_name)-2:
name += "-"
new_name = name
print(new_name)
if os.path.exists(new_name):
continue
else:
os.rename(dir, new_name)
# This affects how many folders are removed that have the same name
# Either change it to a small value and re-run the program or set this to a large integer to delete it in one go
# This will affect the speed of the program, but it wont have a large impact
# Also re-running, won't delete already fixed folders
# Instead of 100, add a large number to make sure you don't have any left over files that didn't get deleted
# I suggest you leave 100 as the integer, because there is very low chance that there will be 101 files with the same name
for i in range(100):
new_list = os.listdir(path)
print(new_list)
for item in range(1, len(new_list)):
if new_list[item].startswith(new_list[item-1]):
print("item removed:", new_list[item])
os.rmdir(new_list[item])
rename_all_files("YOUR PATH HERE")
Edited to also remove leftover files with the same name
Keep in mind that this script will delete only the last part of the file's name
So core-js-jsdbg becomes core-js BUT IF YOU RUN IT AGAIN IT WILL BECOME core
This applies to all files. Every file will get the last part of the last dash removed