PROE软件对模型文件的版本管理是通过后缀来区分的,

所以多次保存后文件夹内文件名字会形如:

abc.prt.1

abc.prt.2

abc.prt.3

cdd.prt.1

等等,久而久之,文件版本就会非常多,会非常臃肿,而且保留过多的历史版本没有太大意义。

proe自带了purge命令可以将旧版本的文件删除,删除后版本号保持最大号,也可以通过备份来实现版本号的重新归一。

所以写了个小脚本,当时python练手。

脚本功能:将purge后得到的文件进行版本归1处理。

 

 
  
  1. """ 
  2. proe 文件夹内文件版本号全部归1脚本 
  3. 1.先利用自带的purge命令去除旧版本 
  4. 2.将dirname改成需要整理的路径名称 
  5. 3.运行即可 
  6. by winxos 2011-02-25 
  7. """ 
  8. import os 
  9. dirname='e:/XZ2011-02-25' 
  10. def reversion(x): 
  11.     ax='' 
  12.     if x[-1]<'0' or x[-1]>'9'
  13.         print(x,"is not proe file!"
  14.         return 
  15.     if x[-4]=='.':ax=x[:-3]+'1' #the older version like .xxx 
  16.     if x[-3]=='.':ax=x[:-2]+'1' #x[-3:] can get the sufix,.xx 
  17.     if x[-2]=='.':ax=x[:-1]+'1' #most happended, .x 
  18.     if ax!='' and ax!=x: #if sufix is 1, no need to  
  19.         print(x,'->',ax) 
  20.         os.chdir(dirname) 
  21.         os.rename(x,ax) 
  22. #main 
  23. for x in os.listdir(dirname):#the main loop 
  24.     reversion(x) 

代码过于简单,不解释,各位不要笑话,

虽然自己用的不好,不过可以看出python挺强的,代码比较短。

winxos 2011-3-1