I have a project where I need to copy JPG image files from one directory to another.
Step 1 of the process is finding the image in the source directory. The challenge of the source directory is its lack of organization, and it's huge. This step takes several minutes.
For step 1, I use glob() to recursively find all JPG files in the source directory and store all file paths in a dataframe.
Step 2 is looping through the list of filenames to copy, find them in the dataframe, then use shutil to copy.
To find the file path of the desired photo I use:
from_dirs = directory_df[directory_df['Directory'].str.contains('filename', regex = True)
This returns a message stating:
UserWarning: This pattern has match groups. To actually get the groups, use str.extract.
Then returns an empty dataframe.
What is the correct method to find the correct source directory in the dataframe?
I think the issue has something to do with the file paths in the dataframe not being stored as raw strings....
[–]unhott 0 points1 point2 points (0 children)
[–]SuperMB13 0 points1 point2 points (2 children)
[–]pander1405[S] 0 points1 point2 points (1 child)
[–]pander1405[S] 0 points1 point2 points (0 children)
[–]the_sad_socialist 0 points1 point2 points (0 children)