I tried to rename all file with extension "XLS;1" to "XLS" but it just didn't work.
I tried the following in cygwin in windows xp and they don't work:
mv *.XLS;1 *.XLS
mv *.XLS\;1 *.XLS
mv "*.XLS;1" *.XLS
I tried to rename all file with extension "XLS;1" to "XLS" but it just didn't work.
I tried the following in cygwin in windows xp and they don't work:
mv *.XLS;1 *.XLS
mv *.XLS\;1 *.XLS
mv "*.XLS;1" *.XLS
The problem isn't the semicolon, your second example would take care of that. The problem is that Linux/Unix utilities (and, by extension, Cygwin) don't take that instruction to mean "move all files ending in .XLS;1
to .XLS
," as I understand Windows does. You need to move each file individually:
for file in *.XLS\;1; do
mv "$file" "${file%;1}"
done
An explanation:
This takes all files ending in .XLS;1
and stores them one at a time into a variable named $file
. For each file, we tell it to move that $file
to a new name we create by chopping ;1
off the back of $file
.
N.b. For those using zsh, there is a nice utility called zmv
:
zmv '(*).XLS;1" "$1.XLS"
Depending on your setup you may need to run autoload zmv
first (put it in your .zshrc too).
You can move by inode.
To find the inode
ls -i
using the inode you just found
find . -inum <you just found> -exec mv {} <new name> \;
That should work on a unix system. No idea about cygwin.
Cygwin has util-linux package which contains rename
:
rename ".XLS;1" ".XLS" *.XLS\;1
Or if there are no other semicolons in the file names, this is enough:
rename ";1" "" *.XLS\;1