help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing file names with "--" to "-" recursively


From: David Masterson
Subject: Re: Changing file names with "--" to "-" recursively
Date: Sun, 21 Feb 2021 22:36:19 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Jean Louis <bugs@gnu.support> writes:

> * wael-zwaiter@gmx.com <wael-zwaiter@gmx.com> [2021-02-21 06:07]:
>> 
>> I have a lot of files and want to change "--" to "-".
>> 
>> Am using
>> 
>> rename 's/--/-/g' *
>> 
>> on the current directory.
>> 
>> How can I recursively go through all sub directories and do the
>> changes for files only.
>
> The command:
>
> $ rename 's/--/-/g' *
>
> does not work on my side as it works on yours, maybe it is different
> software.     
>
> You do as following in the top directory:
>
> for i in $(find . -type f -iname "*--*"); do mv $i $(echo $i | sed -e 
> "s/--/-/"); done
>

That should be "s/--/-/g" to handle files like "aaa--bbb--ccc"

>
> You may alias the command to:
>
> alias renamedashes='for i in $(find . -type f -name "*--*"); do mv $i $(echo 
> $i | sed -e "s/--/-/"); done'
>
> and invoke it with
>
> $ renamedashes
>
> in future.
>

-- 
David Masterson



reply via email to

[Prev in Thread] Current Thread [Next in Thread]