0

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.

1 Answers1

1

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]
Max
  • 85
  • 6
  • 1
    This might be useful for the question in the post but not the question in the title, as it only gives the photo name and not its location. – Max Jan 18 '20 at 16:31
  • Yes, sorry I was unclear. I want to find the location of the picture, that is in some random folder somewhere on the computer. Thank you either way! – Piotr Yartsev Jan 18 '20 at 16:36
  • 1
    No problem, I'm still new too :) maybe these links will help [StackOverflow](https://stackoverflow.com/questions/3964681/find-all-files-in-a-directory-with-extension-txt-in-python) and [Python pathlib Docs](https://docs.python.org/3/library/pathlib.html) – Max Jan 18 '20 at 19:09