zoukankan      html  css  js  c++  java
  • tcl实现批量压缩文件夹

      tcl脚本本身对字符串的处理比较简单,所以想着用这个也实现下:

    proc main {} {
        puts  "请输入路径:"
        set strpath "E:\123"
        set exepath [pwd]
        append exepath "/bin/7z.exe"
        set exepath [string map {"/" "\"} $exepath]
        puts $exepath
        set filelist ""
        cd $strpath
        #puts $strpath
        catch {set filelist [glob *]}
        if {"" == $filelist} {
            puts "目录为空"
            return
        }
        foreach strLine $filelist {
            set strtemp "$strpath\$strLine"
            if {[file isdirectory $strLine]} {
                set str "$strtemp"
                append str ".zip"
                puts $str
                #exec这里不需要判断目录是否有空格,tcl自动处理
                exec $exepath a -tzip $str $strtemp
            }
        }
        puts "_end"
    }
    set strErrInfo ""
    if {[catch {main} strErrInfo]} {
        error "error = $strErrInfo"
    }
  • 相关阅读:
    计算机科学中最重要的32个算法
    趣事
    深度学习迷你地图
    物理学
    代数几何
    Node.js 文件系统
    Node.js 常用工具util包
    Node.js 全局对象
    favi.icon是什么?
    Node.js 路由
  • 原文地址:https://www.cnblogs.com/WaterGood/p/8614185.html
Copyright © 2011-2022 走看看