(I've read different posts and resources uncluding "The Absolute Minimum <...>" but still don't understand how to solve my issue)
I want to feed all files in my dir (and its subdirs) to xmllint
tool. Some files have chinese characters in names.
#!/usr/bin/env python3
import os, sys
import subprocess
fn_folder = "d:/test"
fn_tool_path = 'd:/libxml2-2.9.3-win32-x86_64/bin/xmllint.exe '
for root, subFolders, files in os.walk(fn_folder):
for eachfile in files:
fullname = os.path.join(root,eachfile)
full_cmd = fn_tool_path + '--format ' + fullname
subprocess.Popen(full_cmd)
if, for example, in that d:\test
folder I have 2 files: test1.xml and test2山.xml (chinese character after '2'), then first will be processed correctly while for the second one I'll get warning: failed to load external entity "file:/d:/test/test2%3F.xml"
- i.e. "faulty" character was escaped before passing as an argument. How to avoid this?