|
From: | Jean Louis |
Subject: | Re: Changing file names with "--" to "-" recursively |
Date: | Sun, 21 Feb 2021 09:45:00 +0300 |
User-agent: | Mutt/2.0 (3d08634) (2020-11-07) |
* 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 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.
[Prev in Thread] | Current Thread | [Next in Thread] |