I am trying to use python to rename a filename which contains values such as: ~test1~test2~filename.csv
I want to rename the file to filename.csv. The tildes being my separator for the first two words, and I do not want those words in my finale file name. These words are variables. Any assistance would be appreciated. Thanks!
Since the words change for each file name its best to search a directory for files that match a pattern.
globdoes that for you.If you have a directory like this:
Then running this:
Will give you: