rename file on cygwin

Brian Dessent
Sat Nov 3 07:54:00 GMT 2007

Muhammad Najmi Ahmad Zabidi wrote:

> $ ls *.mp3*
> agama dan aqidah b.mp3@encid=U2FsdGVkX1-SGjIrW9vhJhh1Py
> -h2cpUXJWMQf1Bj04=
> Which I want to rename to this:
> $ ls *.mp3*|awk -F"@*" {'print $1'}
> agama dan aqidah b.mp3
> I tried to use "for" loop but since the old name contains spaces, I've
> to deal with the spaces as well.

Spaces are no problem as long as you quote arguments properly:

for F in *.mp3*; do
	mv -v "$F" "$(echo "$F" | sed -e s,@.*,,)"

> I googled and found the solution of
> using "rename", and my cygwin contains this tool as well.
>  rename.exe -n 's/.mp3*/.m3/' *.mp3*

That is referring to a different version of rename than what comes with
Cygwin.  The Cygwin version is a much simplified version that cannot do
regexps, it is only a blind string replacement tool that has no such -n
(or any other named option.)  It won't be of use to you in this case.


Unsubscribe info:
Problem reports:

More information about the Cygwin mailing list