Capitalize every file in a directory, in bash, using 'svn mv' Capitalize every file in a directory, in bash, using 'svn mv' shell shell

Capitalize every file in a directory, in bash, using 'svn mv'


ls | awk '{system("svn mv " $0 " " toupper(substr($0,1,1)) substr($0,2))}'

obviously, other scripting languages will work just as well. awk has the advantage that it it ubiquitous.


If you have a decent install you should have python, give this a try:

#!/usr/bin/pythonfrom os import rename, listdirpath = "/path/to/folder"try:    dirList = listdir(path)except:    print 'There was an error while trying to access the directory: '+pathfor name in dirList:    try:        rename(path+'\\'+name, path+'\\'+name.upper())    except:        print 'Process failed for file: '+name


I don't think theres an easy way to do it with bash/sed/tr/find.

I'd make a Ruby/Perl script that does the renaming.

 #!/usr/bin/ruby  #  Upcase.rb  ARGV.each{ |i|  newname = i.gsub(/(^.|\s.)/{ |x| x.upcase }  `svn mv "#{i}" "#{newname}" ` }

Then just do

 ./Upcase.rb foo.txt test.txt test2.txt foo/bar/test.txt 

or if you want to do a whole dir

 find ./ -exec ./Upcase.rb {} +