修改目录文件名-Ruby实现
| [日期:2012-01-25] |
来源:Linx社区
作者:eric |
[字体:大 中 小]
|
修改目录文件名-Ruby实现
- require 'pathname'
- def change_name
- puts "------------"
- current_path = Pathname.new(File.dirname(__FILE__)).realpath
- current_file_name = __FILE__
- begin
- Dir::foreach(current_path) do |file|
- if file!="." and file!=".." and file!=".#{ current_file_name }.swp" and file!="#{ current_file_name }"
-
- 1.upto(9) do |i|
- File.rename("#{ i.to_s }#{ i.to_s }.rb", "#{ i.to_s }.rb")
- puts "执行第#{ i }个文件"
- end
- break
- end
- end
- rescue => e
- puts "错误:"+e
-
-
- end
- puts "------------"
- end
-
-
- change_name

评论声明
- 尊重网上道德,遵守中华人民共和国的各项有关法律法规
- 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
- 本站管理人员有权保留或删除其管辖留言中的任意内容
- 本站有权在网站内转载或引用您的评论
- 参与本评论即表明您已经阅读并接受上述条款
|
|
|
|