Created
December 12, 2012 07:55
-
-
Save slacken/4265928 to your computer and use it in GitHub Desktop.
replace all php file's content in current dir with Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #encoding:utf-8 | |
| def startdir(dir) | |
| Dir.foreach(dir){|file| | |
| next if file[0] == '.' | |
| path = dir+file | |
| if File.directory?(path) | |
| startdir(path+'/') | |
| next | |
| end | |
| next unless file[-4,4] == '.php' | |
| content = File.read(path) | |
| if content.include?('聚摊网') | |
| content['聚摊网'] = '聚城' | |
| puts path+":#{content.size}" | |
| File.write(path,content) | |
| end | |
| } | |
| end | |
| startdir('./') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment