0

Dear Stackoverflow moderators: everything I have tried din't work for me.

I have the following Code

def add_song():
       
song = filedialog.askopenfilenames(initialdir=r'C:\Users\kevin\Music')

# add multiple songs 
for song in song:
    # Define the name which should be shown in the textbox
    song.replace(r'C:\Users\kevin\Music', " ")
    song.replace(".mp3", " ")
    
    # place the song in the textbox, textbox name = playlist
    playlist.insert(END,song)

I have already tried it with the replace method, but it didn't work. This is the output in the textbox, but it should only display the song title, without the path and without the .mp3. Also very important: it should work, however what the song path is. I hope you can help me. https://i.stack.imgur.com/6NNmj.png

baumanager
  • 31
  • 7
  • 1
    You might want to research [pathlib](https://docs.python.org/3/library/pathlib.html). There are many methods for parsing paths. – Bryan Oakley Mar 31 '22 at 15:17

0 Answers0