0

Here is the code so far:

import os
from tinytag import TinyTag, TinyTagException

def main():
    for root, dirs, files in os.walk("D:\Desktop\Test"):
        for name_raw in files:
            name_fixed, file_ext = os.path.splitext(name_raw)
            print(name_fixed)
            print('-'*5)
            temp_track = TinyTag.get(root + "\\" + name_raw)
            print(temp_track.artist)
            print('-'*5)
            print(temp_track.title)
            print('-'*5)
            new_name = '{}-{}{}'.format(temp_track.title,temp_track.artist,file_ext)
            os.rename(name_raw,new_name)

main()

The error presented and the files themselves are shown below.

The error

The files

Steak
  • 514
  • 3
  • 15
  • 1
    Your new name isn't a valid windows filepath – Simon Notley Jun 04 '20 at 13:30
  • 1
    Does this answer your question? [What characters are forbidden in Windows and Linux directory names?](https://stackoverflow.com/questions/1976007/what-characters-are-forbidden-in-windows-and-linux-directory-names) – Simon Notley Jun 04 '20 at 13:30
  • I'm not understanding something here: what exactly is not correct about the file naming? I have gotten rid of the Japanese characters in the name, and it is still giving me an error. – Steak Jun 04 '20 at 13:36
  • 1
    You variable new_name contains punctuation and Japanese characters in the example you showed. – Simon Notley Jun 04 '20 at 14:21
  • Sorry - you are totally right. I was just confused - also I don't think the file names can have "?". Thank you! – Steak Jun 04 '20 at 14:34

0 Answers0