Piotr Yartsev
Piotr Yartsev

Reputation: 3

Finding location of picture for folder

I am organizing some books I have on my computer and at the moment they are organized like this:

how the folders with the book packages look: how the folders with the book packages look

how the folders with the books and any supplement material look: how the folders with the books and any supplement material look

I used this method to set the picture for the folders https://winaero.com/blog/change-folder-picture-windows-10/.

I want using python, given a folder directory to find the location of the picture I put as the folder image.

I tried to find the solution online. but could not find anything useful.

Upvotes: 0

Views: 266

Answers (1)

Max
Max

Reputation: 83

If your photos are in the name of your directory then reference this StackOverflow Answer and use the rsplit string method to get everything after the last slash in your directory name.

directory = '/Users/max/Desktop/books/machinelearningcookbook.png'
image_name = directory.rsplit('/', 1)[-1]

Upvotes: 1

Related Questions