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

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -