-1

I have many files for that i want to rename them.

Current Name: 5b011351286e8a042b23ffff\5b011351286e8a042b23ffff_130225_145634.xml

Required Name: 5b011351286e8a042b23ffff_130225_145634.xml

I just want to delete the part before the backslash and the forward slash as well.

I have 500 files for which i want to do same.

Yameen
  • 17

3 Answers3

3

Try:

rename -n 's;.*\\;;s' *.xml

If the results are what you want, run it again without -n. To open a terminal press Ctrl Alt T. Navigate to your Desktop folder:

cd ~/Desktop

Then run the first command. You'll get a response like this:

5b011351286e8a042b23ffff\5b011351286e8a042b23ffff_130225_145634.xml renamed as 5b011351286e8a042b23ffff_130225_145634.xml

And a lot of other lines for all the files matching the conditions. If you're satisfied with the output, then run:

rename 's;.*\\;;s' *.xml

Explanation:

  1. rename is a Perl program (and hence which accepts Perl expressions) for renaming files. The -n option will tell rename to show what it will do, without actually doing anything.
  2. The Perl expression s;.*\\;;s means subsitute for all characters (.*) followed by one backslash (\\ - it needs to escaped, since \ has a special meaning) with nothing (the ; divides each section of the expression) while treating the entire input as a single string.
muru
  • 207,228
1

You can use the rename command:

rename 's/^.*[\\\/]//s' *.xml
1

If the length of you file name is same(till the part you want to change) for all the file in this case you can do it easily with the help of Thunar Bulk Rename which comes with Thunar file manager.

Install it using sudo apt-get install thunar

Now open Bullk Rename from Dash. It has various option for how you want to rename your file. In you case I have create a file with the name you have give, adjusted few parameter and renamed it. enter image description here

g_p
  • 19,034
  • 6
  • 59
  • 69