本组合脚本将tree/f的输出结果以重建文件夹及空文件的形式重建整个文件结构
将- BEGIN {
- Dir_No = 0
- Dir = "."
- Cha_pos = 0
- Dir_FCP = 0
- }
- /^[│├└ ]+[^│├└ ].*$/ {
- if ($0 ~ /^.*[├└]/) {
- Cha_pos = match($0, /[├└]/)
- if (Cha_pos > Dir_FCP) {
- Dir_No++
- No_pos[Cha_pos] = Dir_No
- }
- if (Cha_pos < Dir_FCP) {
- Dir_No = No_pos[Cha_pos]
- }
- Dir_FCP = Cha_pos
- Folder[Dir_No] = gensub(/^.*[├└]─(.+)$/, "\\1", "g", $0)
- Dir = "."
- for (i = 1; i <= Dir_No; i++) {
- Dir = Dir "\\" Folder[i]
- }
- print "mkdir \"" Dir "\">nul 2>&1"
- } else {
- file_name = Dir "\\" (gensub(/^([│ ]+)([^│ ].*)$/, "\\2", "g", $0))
- print "echo;2>\"" file_name "\""
- }
- }
复制代码 以ANSI编码格式保存为tree.awk
将- gawk -f.\tree.awk tree.txt|cmd.exe
复制代码 以ANSI编码格式保存为tree.bat
在命令行窗口执行:复制代码 以获取tree.txt
下载gawk(http://bcn.bathome.net/tool/4.1.0/gawk.exe)
将gawk.exe、tree.awk、tree.txt、tree.bat复制到欲重建文件结构的子文件夹(如D:\test),双击tree.bat执行后即可重建整个文件结构(注:重建后所有的文件均为空文件) |