mv or (git mv) multiple files, preserve extension

540 Views Asked by At

I have about 10 directories, each with contents that match this pattern:

x.js
x.d.ts
x.ts

and I want to rename these files to:

index.js
index.d.ts
index.ts

is there a mv or git mv command that I can use to rename the files?

something like:

git mv --match x.* index.*

I am not really sure.

2

There are 2 best solutions below

0
On

As git does not perform any special rename registration, you can use system utility like rename, then stage the changes. For example with commands:

git add -u
git add <new pattern>
0
On

In a directory, you can use the following command:

rename x index x.*

x.* is the pattern. For all matched file, x will be replaced to index but just for the first occurrence.

Thanks!