Recently see Ecshop to find information on the Internet, found a lot of explanation ecshop file structure is not comprehensive, so want to get a out. But it's a tedious and time-consuming job, and I've written a Python script that recursively iterates through all the files and all subdirectories in the directory and logs the results into an. xml file (because you want to use notepad++ 's code folding feature, so you use an. xml file).
Here's the Python code:
#-*-coding:cp936-*-############################################# # Written by Qian_f # # Get a list of file paths and write Into the current directory build test.txt # ############################################# import os def getfilelist (filepath, tabnum=1): Simple Path = Os.path.split (filepath) [1] returnstr = simplepath+ "directory <>" + "\ n" returndirstr = "" Returnfilestr = "" fi Lelist = Os.listdir (filepath) for NUM in range (len (filelist)): Filename=filelist[num] If Os.path.isdir (filepath+ "/" +filename): Returndirstr + = "\ T" *tabnum+getfilelist (filepath+ "/" +filename, tabnum+1) else:returnfilest r + = "\ t" *tabnum+filename+ "\ n" returnstr + = returnfilestr+returndirstr return returnstr+ "\ T" *tabnum+ "</>\n" Path = raw_input ("Please enter file path:") Usefulpath = path.replace (' \ \ ', '/') if Usefulpath.endswith ("/"): Usefulpath = Usefulpa TH[:-1] If not os.path.exists (Usefulpath): print "Path Error!" Elif not Os.path.isdir (usefulpath): print "input is not directory!" Else: FileList = Os.listdir (USEfulpath) O=open ("Test.xml", "w+") O.writelines (Getfilelist (Usefulpath)) O.close () print "Success!" Please see the Test.xml file "
After executing the Python script, the Test.xml file is generated in the current directory, and the file structure of the specified directory is visible using notepad++ open (ANSI encoding). Here is the file Structure section of the upload directory under the ecshop I generated:
The above is the whole content of this article, I hope that everyone's learning has helped, but also hope that we support topic.alibabacloud.com.