We are running subversion on a Linux server. Someone in our organization overwrote about 3k files with mixed case when they need to all be lowercase.
This works in the CLI
rename 'y/A-Z/a-z/' *
But obviously will screw up subversion.
svn rename 'y/A-Z/a-z/' *
Doesn't work because subversion deals with renames differently I guess. So How can I do this as a batch job? I suck with CLI, so please explain it like I'm your parents. hand renaming all 3k files is not a task I wish to undertake.
Thanks
rename "%f" "%f" - rename the file with its own name, which is actually lowercased by the dir command and /l combination.
Under "Rename" in the Tools menu there are a number of extended rename operations that can be performed. These Rename commands are performed on all selected files and folders. Uppercase / Lowercase renames the selected files/folders to the same name but with all uppercase or all lowercase letters.
Rename files from uppercase to lowercase with mv command Renaming multiple files from uppercase to lowercase with the mv command is easier if you know a little bit of Bash scripting.
for src in *; do
dst=$(echo "$src" | tr '[A-Z]' '[a-z]')
[ "$src" = "$dst ] || svn rename "$src" "$dst"
done
How it works:
||
is pretty common.If you need recursion, you can create a little script svn-lowername.sh
(a slight variant of the above):
#!/bin/bash
for src; do
dst=$(echo "$src" | tr '[A-Z]' '[a-z]')
[ "$src" = "$dst" ] || svn rename "$src" "$dst"
done
Make sure to chmod +x svn-lowername.sh
. Then execute:
find -name .svn -prune -o -type f -print0 | xargs -0 ./svn-lowername.sh
If you think this problem might happen again, stash svn-lowername.sh
in your path somewhere (~/bin/
might be a good spot) and you can then lose the ./
prefix when running it.
You can also use svn-lowername.sh
on just a single dir like this:
./svn-lowername.sh *
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With