posts - 431,  comments - 344,  trackbacks - 0
          D:/ DeleteSVN.py  文件

          #coding=utf-8
          import os
          import shutil
          import sys
          import stat

          def deleteSubFile(svnpath):
              names = os.listdir(svnpath)
              for name in names:
                 
                  fp = os.path.join( svnpath, name)
                  if (os.path.isfile(fp)):
                      os.chmod( fp, stat.S_IWRITE)
                      os.remove(fp)
                  else:
                      deleteSubFile(fp)
                      

          def deleteSVN(parentPath = None, dir = None):
              if (dir != None and dir == '.svn'):
                  deleteSubFile(os.path.join( parentPath, dir))
                  shutil.rmtree(os.path.join( parentPath, dir), True, False)
                  print 'deleted ', os.path.join( parentPath, dir)
              else:
                  if (dir != None):
                      filePath = os.path.join( parentPath, dir)
                  else:
                      filePath = parentPath
                  names = os.listdir(filePath)
                  for name in names:
                      fp = os.path.join( filePath, name)
                      if (os.path.isdir(fp)):
                          deleteSVN(filePath, name)


          if len(sys.argv) < 2:
              print 'Usage: python % <file path>' % os.path.basename(sys.argv[0])
              sys.exit(-1)

          if os.path.isfile(sys.argv[1]):
              print '請選擇文件夾, 而不是文件'
          else:
              deleteSVN(parentPath = sys.argv[1])



          bat文件代碼如下:
          python D:/DeleteSVN.py "%1"
          @pause

          這樣把包含svn文件的文件夾直接拉到bat文件中, 就會刪除掉里面所有svn文件
          posted on 2009-06-12 23:19 周銳 閱讀(405) 評論(0)  編輯  收藏 所屬分類: Python
          主站蜘蛛池模板: 泊头市| 海南省| 安多县| 新干县| 松原市| 海伦市| 罗源县| 格尔木市| 阿荣旗| 当阳市| 江永县| 南江县| 南投市| 北票市| 沭阳县| 六安市| 滨海县| 寻乌县| 信宜市| 长子县| 油尖旺区| 探索| 甘洛县| 山东省| 天祝| 内江市| 葫芦岛市| 旅游| 梧州市| 门源| 漳州市| 海丰县| 喀喇| 调兵山市| 莱芜市| 泾阳县| 积石山| 杂多县| 宁蒗| 定西市| 祁连县|