I am working on a script where I need to created a sub-directory inside a directory. The main directory contains a large number of .tif images (8000-9000) of which I am sorting into the sub-directory based on specific conditions of the image information.
My issue is that when I use os.path.exists and os.path.isdir, both yield 'True'. However, when using terminal to access the sub-directory (or even through VSCode), it is said to not exist.
Example of what I have done in terms of code given here:
Edit: providing the absolute path of the directory and sub-directory I would like to create.
import os
import shutil
import cv2
import numpy as np
path = '/home/proy/pm/AF_patch/block_01_01_AF_reg' #contains .tif files
path2 = 'background_removed_patch'
new_path = os.path.join(path, path2)
print(new_path) # yields correct sub-directory to be created
os.makedirs(new_path)
print(os.path.exists('/pm/AF_patch/block_01_01_AF_reg/background_removed_patch')) #yield true
print(os.path.isdir('/pm/AF_patch/block_01_01_AF_reg/background_removed_patch')) #yield true
Despite the path being said to exist, when trying to access the new directory through terminal, I get:
(base) [proy@login-0 block_01_01_AF_reg]$ cd background_removed_patch
bash: cd: background_removed_patch: No such file or directory
Any ideas or information regarding a solution for this would be much appreciated. Essentially I am trying to create this directory (absolute path):
/home/proy/pm/AF_patch/block_01_01_AF_reg/background_removed_patch
Current working directory from os.getcwd is given as `/home/proy/pm'.
Thank you for the help.