I'd like to move a file from one directory to another by filtering the filename with a specific string
Seems like fnmatch or glob can do this but I can't figure it out
In the example below, how could python move only the file test_High_Quality.mb to another directory using the filter High_Quality in the filename
>>> import os
>>> myPath = "C:\Project"
>>> os.listdir('myPath')
>>> ['test_Draft.txt', 'test_Mid_Quality.txt', 'test_High_Quality.txt']
To filter with file names "High_Quality"
[d for d in os.listdir('myPath') if 'High_Quality' in d]
For moving to other directory, follow this solution similar question
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With