rename - How to use Python to replace all filenames that contain Chinese characters in several folders? -
the directory names , file names both contain chinese characters. i'd able convert english version. can make dictionary of {chinese:english}, have difficulties in getting file names os.walk. can help? new python. thanks.
when you're having trouble mean? use os.walk() such:
for root, dirs, files in os.walk('path/to/directory'): [logic within each directory]
os.walk() creates generator of tuples of form (dirpath, dirnames, filenames) walk recursively through current folder , subsequent folders. can use elements of files filenames, dirs directory names in current directory, , root root directory both files , directories. use os.rename(). see: docs
Comments
Post a Comment