I am trying to list/copy the files with pattern for example name_123.jpg from 1 folder to other ..
Does anyone have any suggestion
I am trying to list/copy the files with pattern for example name_123.jpg from 1 folder to other ..
Does anyone have any suggestion
Generally it helps a lot for you to post your code and attempts so it's easy to decipher where you're going wrong. Nevertheless, I'll try to help really quickly.
Copying files is straightforward in python. See this post for good explanations of the different methods.
It also sounds like you want to list files in a certain directory. From this great post, I got the following code:
from os import listdir
from os.path import isfile, join
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
After running this, onlyFiles will be a list of the different paths of each file.
Finally, it sounds like you only want to grab files that have a certain pattern in the filename. Each path is really just a string, so, you can use the standard methods for searching through strings to grab the pattern. Here's an example:
filtered_names = [x for x in onlyFiles if "name_" in x]
I hope this helps. Generally, before posting a question, please search through Stack Overflow first (The posts I linked were the top google result and have millions of views). Additionally, please post code and attempts.