Showing posts with label pathlib. Show all posts
Showing posts with label pathlib. Show all posts

12/13/2022

search all certain files recursively including subfolder - python example

 

refer to code

..

from pathlib import Path
mypath = "folder1/folder2"
for path in Path(annotation_addr).rglob('*.json'):
print(path) #full path
print(path.name) #file name

..


Thank you.

www.marearts.com

πŸ™‡πŸ»‍♂️

5/14/2022

pathlib, path, pathlib.PosixPath,

 

Make path using pathlib.

refer to code

..

from pathlib import Path
image_dir = 'dataset/images'
images = '1.png'
print(str(Path(image_dir) / images))
print( type(Path(image_dir) / images ))
# dataset/images/1.png
# <class 'pathlib.PosixPath'>

..


www.marearts.com