Code to change poster names from James Bond.png to James Bond/poster.png #8
meisnate12
started this conversation in
Show and tell
Replies: 1 comment
-
Hi I've added some modifications to your script I would like to share. This will traverse through each folder recursively making it useful if you want to add posters for the movies inside the collection as well. import os
folder = "./assets"
for dirpath, dirs, files in os.walk(folder):
for filename in files:
name, ext = os.path.splitext(filename)
fname = os.path.join(dirpath,filename)
if name != 'poster' and name != 'background':
os.makedirs(os.path.join(dirpath, name),exist_ok=True)
os.rename(os.path.join(dirpath, filename), os.path.join(dirpath, name, "poster{}".format(ext))) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If you have a folder with a bunch of Images in it named after collections like
James Bond.png
and you want them to be inside a folder named poster.png likeJames Bond/poster.png
you can use the code below just change<PATH_TO_FODLER>
to your folder path and then every file inside will be converted to a folder.Beta Was this translation helpful? Give feedback.
All reactions