I want to use python to check if any mp3 files exist in a specified directory. If it does exist, I want to store the file path in a variable.
Here is some code I have to check if any file exists. How can I modify it?
import os
dir = os.path.dirname(__file__) or '.'
dir_path = os.path.join(dir, '../folder/')
onlyfiles = [f for f in os.listdir(dir_path) if os.path.isfile(os.path.join(dir_path, f))]