0

I want to find out whether the paths have 'video' and 'image' folder present or not. I only have this list as my input. I don't have the path present in my system.

all_path = ["my_path/output/12345/video/folder/1","my_path/output/12345/video/folder/2","my_path/output/12345/video/folder/3","my_path/output/98745/video/folder/1","my_path/output/98745/video/folder/2","my_path/output/90000/video/folder/1",......,"my_path/output/12345/image/folder/10","my_path/output/12345/image/folder/9","my_path/output/12345/image/folder/8","my_path/output/98745/image/folder/3","my_path/output/98745/image/folder/9","my_path/output/11145/image/folder/8",......]

subfolder_startswith = ["video","image"]

Output:

11145: video
90000: image

As in folder 11145, there is no sub folder name as video. And in 90000 no sub folder name as image

Beyond
  • 21
  • 3
  • `if "video" in path:` and `path.split("/")` should get you most of the way there - where's your code? Questions need an [mcve]. – Jack Deeth Oct 20 '22 at 17:21
  • 2
    Does this answer your question? [How do I check if directory exists in Python?](https://stackoverflow.com/questions/8933237/how-do-i-check-if-directory-exists-in-python) – picobit Oct 20 '22 at 17:21
  • Why did you tag this with both "python-3.x" AND "python-2.7"? That doesn't make sense. Please, as a new user here, take the [tour] and read [ask]. Also, do some basic research! File and path handling isn't obscure fringe tech, it's commonplace. – Ulrich Eckhardt Oct 20 '22 at 18:30
  • Actualy I don't have the path present in my system. It's a simulated output from other and it's a input for me – Beyond Oct 20 '22 at 18:33
  • Sorry. I will delete python2.7 – Beyond Oct 20 '22 at 18:34

0 Answers0