I'm trying to create a small script that copies files with partially unicode names in variables, but I just can't get it to work.
The code looks like this:
fileextension = filename.split(".")[len(filename.split(".")) - 1]
if not os.path.exists(artistdir + "\\" + songname + "." + fileextension):
print basedir + filename, artistdir + "\\" + songname + "." + fileextension
shutil.copy(basedir + filename, artistdir + "\\" + songname + "." + fileextension)
I get the following return:
E:\music\_collections\Adrian von Ziegler\2012 Starchaser\01. Adrian von Ziegler - Nidh├Âggr.mp3 C:\Temp\Adrian von Ziegler\Nidh├Âggr.mp3
Traceback (most recent call last):
File "E:\main\Coding\Python\WinampPlaylistExport\winampplaylistexport.py", line 72, in <module>
iteratePlaylists()
File "E:\main\Coding\Python\WinampPlaylistExport\winampplaylistexport.py", line 20, in iteratePlaylists
iteratePlaylist(playlist.get("title"), playlist.get("filename"))
File "E:\main\Coding\Python\WinampPlaylistExport\winampplaylistexport.py", line 69, in iteratePlaylist
shutil.copy(basedir + filename, artistdir + "\\" + songname + "." + fileextension)
File "C:\Python27\lib\shutil.py", line 119, in copy
copyfile(src, dst)
File "C:\Python27\lib\shutil.py", line 82, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: 'E:\\music\\_collections\\Adrian von Ziegler\\2012 Starchaser\\01. Adrian von Ziegler - Nidh\xc3\xb6ggr.mp3'
The first line shows the target and the source path of the file where the copying fails (return of the print statement).
Thanks in advance.