Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I need to change the capitalization of a set of files in a subversion working copy, like so:

svn mv test.txt Test.txt
svn mv test2.txt Test2.txt
svn mv testn.txt Testn.txt
...
svn commit -m "caps"

How can I automate this process? Standard linux install tools available.

like image 312
Alex J Avatar asked Oct 13 '08 23:10

Alex J


2 Answers

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.

like image 61
ejgottl Avatar answered Sep 22 '22 00:09

ejgottl


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

#!/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
like image 29
UnkwnTech Avatar answered Sep 18 '22 00:09

UnkwnTech