在bash中,使用';svn mv&x27;
我需要更改subversion工作副本中一组文件的大小写,如下所示: svn mv test.txt Test.txt svn mv test2.txt Test2.txt svn mv testn.txt Testn.txt ... svn commit -m "caps" svn mv test.txt test.txt svn mv test2.txt test2.txt svn mv testn.txt testn.txt ... svn提交-m“caps”在bash中,使用';svn mv&x27;,svn,shell,file,batch-file,rename,Svn,Shell,File,Batch File,Rename,我需要更改subversion工作副本中一组文件的大小写,如下所示: svn mv test.txt Test.txt svn mv test2.txt Test2.txt svn mv testn.txt Testn.txt ... svn commit -m "caps" svn mv test.txt test.txt svn mv test2.txt test2.txt svn mv testn.txt testn.txt ... svn提交-m“caps” 如何使此过程自动化?标准的l
如何使此过程自动化?标准的linux安装工具可用。我通常通过将“ls”输出重定向到一个文件,使用vim宏将每个文件名传递到我想要的命令行中,然后将该文件作为shell脚本执行。它很粗糙,但很有效。如果你有一个像样的安装,你应该有python,试试看:
#!/usr/bin/python
from os import rename, listdir
path = "/path/to/folder"
try:
dirList = listdir(path)
except:
print 'There was an error while trying to access the directory: '+path
for name in dirList:
try:
rename(path+'\\'+name, path+'\\'+name.upper())
except:
print 'Process failed for file: '+name
ls | awk{系统(“svn mv”$0“toupper(substr($0,1,1))substr($0,2))}'
显然,其他脚本语言也可以工作。awk的优势在于它无处不在。我认为使用bash/sed/tr/find并不是一种简单的方法 我将制作一个Ruby/Perl脚本来进行重命名
#!/usr/bin/ruby
# Upcase.rb
ARGV.each{ |i|
newname = i.gsub(/(^.|\s.)/{ |x| x.upcase }
`svn mv "#{i}" "#{newname}" `
}
那就做吧
./Upcase.rb foo.txt test.txt test2.txt foo/bar/test.txt
或者如果你想做一个完整的dir
find ./ -exec ./Upcase.rb {} +
请注意,此更改会破坏Windows和Mac系统上现有的工作副本,因为它们无法处理仅大小写重命名。name.capitalize(),而不是upper(),这取决于需要什么,如果他需要“Filename”,那么是的,你是对的,但是我假设需要“Filename”,在这种情况下我是对的。如果你阅读了他的问题,很明显,他想要的是“文件名”而不是“文件名”。很好,就是我要找的那一行!在Subversion=1.7时,进行更新以防更改可能会注意到一些障碍,但您可以从该状态恢复,而不会使工作副本损坏。