Rename all files with the same extension and any name

snowfinch27

I need to rename all files with .js extension, but names of files can vary, for example:

rootDirectory
--firstDirectory
----first.js
--secondFileDirectory
----second.js
--thirdDirectory
----third.js

Needs to be renamed to

rootDirectory
--firstDirectory
----newName.js
--secondFileDirectory
----newName.js
--thirdDirectory
----newName.js

Is there a way to do it?

I'm using Ubuntu 14.04

Stephen Harris

Ububtu 14 has a version of find that has the -execdir option, so this becomes relatively simple:

find . -name '*.js' -execdir mv -i {} newName.js \;

For example, I have this tree:

./A
./A/first.js
./B
./B/second.js

I run the command

$ find . -name '*.js' -execdir mv -i {} newName.js \;

The resulting tree:

./A
./A/newName.js
./B
./B/newName.js

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Rename all files with same base name

From Dev

Rename all files in directory while preserving any file extension

From Dev

Recurse through subdirectories and rename all files of a given extension the same filename

From Dev

How to efficiently rename all files/directories with same name?

From Dev

Rename All Files with a Certain Name

From Dev

bash - Find All Files with Same Name Regardless of Extension

From Dev

Rename files in subdirectory with the same name as the name of the folder

From Dev

Rename all files found by extension in for loop

From Dev

how to rename all files under folder with specific extension name ( recursive approach )

From Dev

Rename files with same name but differing extensions

From Dev

How to rename files with same name as parent folder

From Dev

Rename files of the same name in multiple subdirectories

From Dev

Rename all files's name in Python

From Dev

Rename Files to Same Filename Without Extension with find Command

From Dev

How do I copy variously named files with the same extension to all have a standard file name?

From Dev

Renaming Files With Same Name, Different Extension in Linux:

From Dev

Delete files same name but different file extension

From Dev

How To Rename The Extension of All The Files In A Directory Tree With Command Prompt

From Dev

How To Rename The Extension of All The Files In A Directory Tree With Command Prompt

From Dev

Rename the extension of many files

From Dev

Rename the extension of many files

From Dev

Display file name of all files with certain extension

From Dev

Move all files with same extension at once in ruby

From Dev

Move all files with same extension at once in ruby

From Dev

list all the files with the same extension as specified by the user

From Dev

Move all Files of same extension to a Folder

From Dev

Recursively copy (and rename) files to their own same directory with another name

From Dev

Recursively copy (and rename) files to their own same directory with another name

From Dev

Unziping multiple ziped and rename automatically files with same name if needed

Related Related

  1. 1

    Rename all files with same base name

  2. 2

    Rename all files in directory while preserving any file extension

  3. 3

    Recurse through subdirectories and rename all files of a given extension the same filename

  4. 4

    How to efficiently rename all files/directories with same name?

  5. 5

    Rename All Files with a Certain Name

  6. 6

    bash - Find All Files with Same Name Regardless of Extension

  7. 7

    Rename files in subdirectory with the same name as the name of the folder

  8. 8

    Rename all files found by extension in for loop

  9. 9

    how to rename all files under folder with specific extension name ( recursive approach )

  10. 10

    Rename files with same name but differing extensions

  11. 11

    How to rename files with same name as parent folder

  12. 12

    Rename files of the same name in multiple subdirectories

  13. 13

    Rename all files's name in Python

  14. 14

    Rename Files to Same Filename Without Extension with find Command

  15. 15

    How do I copy variously named files with the same extension to all have a standard file name?

  16. 16

    Renaming Files With Same Name, Different Extension in Linux:

  17. 17

    Delete files same name but different file extension

  18. 18

    How To Rename The Extension of All The Files In A Directory Tree With Command Prompt

  19. 19

    How To Rename The Extension of All The Files In A Directory Tree With Command Prompt

  20. 20

    Rename the extension of many files

  21. 21

    Rename the extension of many files

  22. 22

    Display file name of all files with certain extension

  23. 23

    Move all files with same extension at once in ruby

  24. 24

    Move all files with same extension at once in ruby

  25. 25

    list all the files with the same extension as specified by the user

  26. 26

    Move all Files of same extension to a Folder

  27. 27

    Recursively copy (and rename) files to their own same directory with another name

  28. 28

    Recursively copy (and rename) files to their own same directory with another name

  29. 29

    Unziping multiple ziped and rename automatically files with same name if needed

HotTag

Archive