Thank you Gregory for your answer, This is doing the rename to avoid the overwriting which is great! The only problem is the "with a decent name" part that is missing, this is changing the file extension. gmv --backup=t foo.tar bar.tar will result in bar.tar bar.tar.~1~ is there any way to be a bit smarter than that?
Best regards Stephane Archer On Mon, Dec 5, 2022 at 1:05 PM Gregory Heytings <greg...@heytings.org> wrote: > > > > > I'm using the shell every day but there is one thing that terribly > > annoys me. > > > > When moving files, if two files have the same name, you can overwrite it > > with the default behavior, not move the file with -n or choose between > > the two with -i, from my understanding the is no way to tell mv to > > rename the file to avoid the overwrite with a decent name like img_2.jpg > > for img.jpg > > > > Can you add this feature to mv? > > > > You can use the --backup option. For example, > > mv --force --backup=t foo bar > > will make a backup of bar in bar.~1~ before overwriting bar with foo. > -- Best Regards, Stephane Archer