How do I move numbers in filenames, in a batch renaming operation?
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgO9GURib1T8z7lCwjOGLQaGtrueEthgQ8LO42ZX8cOfTqDK4jvDDpKkLFwf2J49kYCMNW7d4ABih_XCb_2UXdq5fPJDkoyg7-8g_YfRUot-XnaXkNYycsNp7lA5_TW9td0FFpLQ2APzKcZ/s1600/1.jpg)
![Creative The name of the picture](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYQ0N5W1qAOxLP7t7iOM6O6AzbZnkXUy16s7P_CWfOb5UbTQY_aDsc727chyphenhyphen5W4IppVNernMMQeaUFTB_rFzAd95_CDt-tnwN-nBx6JyUp2duGjPaL5-VgNO41AVsA_vu30EJcipdDG409/s400/Clash+Royale+CLAN+TAG%2523URR8PPP.png)
up vote
10
down vote
favorite
I have been trying to figure out how to rename files for the past few hours.
I have 2000 files that are like this:
file.1.pdb
file.2.pdb
file.3.pdb
I would like to rename these files to something like:
file.pdb.1
file.pdb.2
file.pdb.3
command-line batch-rename
 |Â
show 2 more comments
up vote
10
down vote
favorite
I have been trying to figure out how to rename files for the past few hours.
I have 2000 files that are like this:
file.1.pdb
file.2.pdb
file.3.pdb
I would like to rename these files to something like:
file.pdb.1
file.pdb.2
file.pdb.3
command-line batch-rename
Didn't you mean bash?
â avazula
Mar 29 at 15:38
4
@avazula No please read this article : en.wikipedia.org/wiki/Batch_renaming
â Ali Razmdideh
Mar 29 at 15:47
@PerlDuck yes ;)
â Ali Razmdideh
Mar 29 at 15:52
6
Possible duplicate of How to easily rename files using command line?
â wjandrea
Mar 29 at 16:09
2
Hey close voters - do you all really think we only need one question in the [batch-rename] tag? Is there anything in the linked post that actually helps with the task in this question, except the idea of usingrename
? It seems to me that if a batch renaming question has specific details, we should just provide specific answers to it.
â Zanna
Mar 31 at 9:41
 |Â
show 2 more comments
up vote
10
down vote
favorite
up vote
10
down vote
favorite
I have been trying to figure out how to rename files for the past few hours.
I have 2000 files that are like this:
file.1.pdb
file.2.pdb
file.3.pdb
I would like to rename these files to something like:
file.pdb.1
file.pdb.2
file.pdb.3
command-line batch-rename
I have been trying to figure out how to rename files for the past few hours.
I have 2000 files that are like this:
file.1.pdb
file.2.pdb
file.3.pdb
I would like to rename these files to something like:
file.pdb.1
file.pdb.2
file.pdb.3
command-line batch-rename
command-line batch-rename
edited Mar 29 at 21:36
Eliah Kagan
79.6k20222359
79.6k20222359
asked Mar 29 at 15:33
user812758
513
513
Didn't you mean bash?
â avazula
Mar 29 at 15:38
4
@avazula No please read this article : en.wikipedia.org/wiki/Batch_renaming
â Ali Razmdideh
Mar 29 at 15:47
@PerlDuck yes ;)
â Ali Razmdideh
Mar 29 at 15:52
6
Possible duplicate of How to easily rename files using command line?
â wjandrea
Mar 29 at 16:09
2
Hey close voters - do you all really think we only need one question in the [batch-rename] tag? Is there anything in the linked post that actually helps with the task in this question, except the idea of usingrename
? It seems to me that if a batch renaming question has specific details, we should just provide specific answers to it.
â Zanna
Mar 31 at 9:41
 |Â
show 2 more comments
Didn't you mean bash?
â avazula
Mar 29 at 15:38
4
@avazula No please read this article : en.wikipedia.org/wiki/Batch_renaming
â Ali Razmdideh
Mar 29 at 15:47
@PerlDuck yes ;)
â Ali Razmdideh
Mar 29 at 15:52
6
Possible duplicate of How to easily rename files using command line?
â wjandrea
Mar 29 at 16:09
2
Hey close voters - do you all really think we only need one question in the [batch-rename] tag? Is there anything in the linked post that actually helps with the task in this question, except the idea of usingrename
? It seems to me that if a batch renaming question has specific details, we should just provide specific answers to it.
â Zanna
Mar 31 at 9:41
Didn't you mean bash?
â avazula
Mar 29 at 15:38
Didn't you mean bash?
â avazula
Mar 29 at 15:38
4
4
@avazula No please read this article : en.wikipedia.org/wiki/Batch_renaming
â Ali Razmdideh
Mar 29 at 15:47
@avazula No please read this article : en.wikipedia.org/wiki/Batch_renaming
â Ali Razmdideh
Mar 29 at 15:47
@PerlDuck yes ;)
â Ali Razmdideh
Mar 29 at 15:52
@PerlDuck yes ;)
â Ali Razmdideh
Mar 29 at 15:52
6
6
Possible duplicate of How to easily rename files using command line?
â wjandrea
Mar 29 at 16:09
Possible duplicate of How to easily rename files using command line?
â wjandrea
Mar 29 at 16:09
2
2
Hey close voters - do you all really think we only need one question in the [batch-rename] tag? Is there anything in the linked post that actually helps with the task in this question, except the idea of using
rename
? It seems to me that if a batch renaming question has specific details, we should just provide specific answers to it.â Zanna
Mar 31 at 9:41
Hey close voters - do you all really think we only need one question in the [batch-rename] tag? Is there anything in the linked post that actually helps with the task in this question, except the idea of using
rename
? It seems to me that if a batch renaming question has specific details, we should just provide specific answers to it.â Zanna
Mar 31 at 9:41
 |Â
show 2 more comments
6 Answers
6
active
oldest
votes
up vote
15
down vote
If you have rename
installed, you can use
rename -n 's/(.d+).pdb$/.pdb$1/' *.pdb # just watch what WOULD happen
rename 's/(.d+).pdb$/.pdb$1/' *.pdb # actually rename the files
The command rename
can be installed via
sudo apt install rename
add a comment |Â
up vote
11
down vote
Through mmv
(rename multiple files by wildcard patterns) it's mush easy:
mmv '*.*.*' '#1.#3.#2' *.pdb
or zmv
of zsh
shell; it's a module that allows to do rename; see ZMV-Examples:
zmv -w '*.*.*' '$1.$3.$2' *.pdb
3
Bothmmv
andzmv
seem rather exotic to me. Do you mind elaborating a bit what they are and what they do?
â PerlDuck
Mar 29 at 18:10
2
I added a links to their manpage and examples.
â Ã±ÃÂsýù÷
Mar 29 at 18:36
mmv
is pretty cool. Seems better-suited to this kind of renaming thanrename
, albeit being less flexible in terms of name matching.
â JAB
Mar 30 at 20:11
add a comment |Â
up vote
10
down vote
Using Perl rename
:
rename -n 's/(.d+)(.pdb)/$2$1/' *.pdb
Quick explanation:
*.pdb
Match all files that end with.pdb
. (Done by the shell)(.d+)
Match a literal dot, then one or more decimal digits. The parens create a match group.$2$1
Reverse the first and second match groups.-n
No action (simulate). If the output looks good, run the command again without this flag.
1
LOL. Same thought. You were 48 seconds quicker.
â PerlDuck
Mar 29 at 16:02
1
@PerlDuck Lol, yeah, same thought. The answers complement quite well too: you cover installation, I cover syntax.
â wjandrea
Mar 29 at 16:04
@wjandrea ALWAYS run rename with-n
first.
â Calimo
Mar 30 at 8:59
@Calimo Good point. Edited to add that.
â wjandrea
Mar 30 at 21:13
add a comment |Â
up vote
7
down vote
You can use this script:
for i in `seq 1 2000`; do
mv file.$i.pdb file.pdb.$i
done
Or this copy-paste friendly command:
for i in `seq 1 2000`; do mv file.$i.pdb file.pdb.$i; done
For use above commands, put all 2000 files in one folder and then open terminal in that directory, then run above command in it.
add a comment |Â
up vote
5
down vote
Recently nautilus, the default file manager, received a batch rename dialog. It is not yet powerful enough to do what you want. But luckily there is thunar, an alternative file manager that can be installed. With thunars rename dialog you can do what you want using the GUI.
First install thunar:
sudo apt install thunar
Start thunar, navigate to the directory that has your files. Then select all of them. Press F2.
In the dialog that opens, again, select all files. Change mode to "Search & Replace" and to "Name & Suffix". Check "Regular Expression". Now use the following as search and replace patterns:
file.(.+).pdb
and
file.pdb.$1
Finally click the rename button.
The advantage of this way is that you get a visual preview of what will happen before you actually do the renaming.
1
You can make most programs print English messages by prefixing the command withLC_MESSAGES=POSIX
, e. g.LC_MESSAGES=POSIX free
. Works the same for graphical applications although in the case of persistent applications like Nautilus in its default configuration you need to terminate the previous instance withnautilus -q
first.
â David Foerster
Mar 30 at 16:00
@DavidFoerster thanks for mentioning, image replaced.
â Sebastian Stark
Mar 30 at 22:50
add a comment |Â
up vote
3
down vote
You can use rename
from util-linux
for this (the command is called rename.ul
in ubuntu):
rename.ul .pdb '' *
rename.ul "file." "file.pdb." *
This first removes the .pdb
extension from the end and then re-inserts it into the middle.
1
Pretty cool. I wasn't aware ofrename.ul
. The syntax is a bit, um, unexpected, but it actually works the way you advertise. Plus: it also has a-n
(don't touch, just tell) switch.
â PerlDuck
Mar 29 at 17:40
add a comment |Â
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
15
down vote
If you have rename
installed, you can use
rename -n 's/(.d+).pdb$/.pdb$1/' *.pdb # just watch what WOULD happen
rename 's/(.d+).pdb$/.pdb$1/' *.pdb # actually rename the files
The command rename
can be installed via
sudo apt install rename
add a comment |Â
up vote
15
down vote
If you have rename
installed, you can use
rename -n 's/(.d+).pdb$/.pdb$1/' *.pdb # just watch what WOULD happen
rename 's/(.d+).pdb$/.pdb$1/' *.pdb # actually rename the files
The command rename
can be installed via
sudo apt install rename
add a comment |Â
up vote
15
down vote
up vote
15
down vote
If you have rename
installed, you can use
rename -n 's/(.d+).pdb$/.pdb$1/' *.pdb # just watch what WOULD happen
rename 's/(.d+).pdb$/.pdb$1/' *.pdb # actually rename the files
The command rename
can be installed via
sudo apt install rename
If you have rename
installed, you can use
rename -n 's/(.d+).pdb$/.pdb$1/' *.pdb # just watch what WOULD happen
rename 's/(.d+).pdb$/.pdb$1/' *.pdb # actually rename the files
The command rename
can be installed via
sudo apt install rename
answered Mar 29 at 16:00
![](https://i.stack.imgur.com/kCmqs.png?s=32&g=1)
![](https://i.stack.imgur.com/kCmqs.png?s=32&g=1)
PerlDuck
3,92811030
3,92811030
add a comment |Â
add a comment |Â
up vote
11
down vote
Through mmv
(rename multiple files by wildcard patterns) it's mush easy:
mmv '*.*.*' '#1.#3.#2' *.pdb
or zmv
of zsh
shell; it's a module that allows to do rename; see ZMV-Examples:
zmv -w '*.*.*' '$1.$3.$2' *.pdb
3
Bothmmv
andzmv
seem rather exotic to me. Do you mind elaborating a bit what they are and what they do?
â PerlDuck
Mar 29 at 18:10
2
I added a links to their manpage and examples.
â Ã±ÃÂsýù÷
Mar 29 at 18:36
mmv
is pretty cool. Seems better-suited to this kind of renaming thanrename
, albeit being less flexible in terms of name matching.
â JAB
Mar 30 at 20:11
add a comment |Â
up vote
11
down vote
Through mmv
(rename multiple files by wildcard patterns) it's mush easy:
mmv '*.*.*' '#1.#3.#2' *.pdb
or zmv
of zsh
shell; it's a module that allows to do rename; see ZMV-Examples:
zmv -w '*.*.*' '$1.$3.$2' *.pdb
3
Bothmmv
andzmv
seem rather exotic to me. Do you mind elaborating a bit what they are and what they do?
â PerlDuck
Mar 29 at 18:10
2
I added a links to their manpage and examples.
â Ã±ÃÂsýù÷
Mar 29 at 18:36
mmv
is pretty cool. Seems better-suited to this kind of renaming thanrename
, albeit being less flexible in terms of name matching.
â JAB
Mar 30 at 20:11
add a comment |Â
up vote
11
down vote
up vote
11
down vote
Through mmv
(rename multiple files by wildcard patterns) it's mush easy:
mmv '*.*.*' '#1.#3.#2' *.pdb
or zmv
of zsh
shell; it's a module that allows to do rename; see ZMV-Examples:
zmv -w '*.*.*' '$1.$3.$2' *.pdb
Through mmv
(rename multiple files by wildcard patterns) it's mush easy:
mmv '*.*.*' '#1.#3.#2' *.pdb
or zmv
of zsh
shell; it's a module that allows to do rename; see ZMV-Examples:
zmv -w '*.*.*' '$1.$3.$2' *.pdb
edited Mar 29 at 18:35
answered Mar 29 at 17:59
ñÃÂsýù÷
23.4k2192152
23.4k2192152
3
Bothmmv
andzmv
seem rather exotic to me. Do you mind elaborating a bit what they are and what they do?
â PerlDuck
Mar 29 at 18:10
2
I added a links to their manpage and examples.
â Ã±ÃÂsýù÷
Mar 29 at 18:36
mmv
is pretty cool. Seems better-suited to this kind of renaming thanrename
, albeit being less flexible in terms of name matching.
â JAB
Mar 30 at 20:11
add a comment |Â
3
Bothmmv
andzmv
seem rather exotic to me. Do you mind elaborating a bit what they are and what they do?
â PerlDuck
Mar 29 at 18:10
2
I added a links to their manpage and examples.
â Ã±ÃÂsýù÷
Mar 29 at 18:36
mmv
is pretty cool. Seems better-suited to this kind of renaming thanrename
, albeit being less flexible in terms of name matching.
â JAB
Mar 30 at 20:11
3
3
Both
mmv
and zmv
seem rather exotic to me. Do you mind elaborating a bit what they are and what they do?â PerlDuck
Mar 29 at 18:10
Both
mmv
and zmv
seem rather exotic to me. Do you mind elaborating a bit what they are and what they do?â PerlDuck
Mar 29 at 18:10
2
2
I added a links to their manpage and examples.
â Ã±ÃÂsýù÷
Mar 29 at 18:36
I added a links to their manpage and examples.
â Ã±ÃÂsýù÷
Mar 29 at 18:36
mmv
is pretty cool. Seems better-suited to this kind of renaming than rename
, albeit being less flexible in terms of name matching.â JAB
Mar 30 at 20:11
mmv
is pretty cool. Seems better-suited to this kind of renaming than rename
, albeit being less flexible in terms of name matching.â JAB
Mar 30 at 20:11
add a comment |Â
up vote
10
down vote
Using Perl rename
:
rename -n 's/(.d+)(.pdb)/$2$1/' *.pdb
Quick explanation:
*.pdb
Match all files that end with.pdb
. (Done by the shell)(.d+)
Match a literal dot, then one or more decimal digits. The parens create a match group.$2$1
Reverse the first and second match groups.-n
No action (simulate). If the output looks good, run the command again without this flag.
1
LOL. Same thought. You were 48 seconds quicker.
â PerlDuck
Mar 29 at 16:02
1
@PerlDuck Lol, yeah, same thought. The answers complement quite well too: you cover installation, I cover syntax.
â wjandrea
Mar 29 at 16:04
@wjandrea ALWAYS run rename with-n
first.
â Calimo
Mar 30 at 8:59
@Calimo Good point. Edited to add that.
â wjandrea
Mar 30 at 21:13
add a comment |Â
up vote
10
down vote
Using Perl rename
:
rename -n 's/(.d+)(.pdb)/$2$1/' *.pdb
Quick explanation:
*.pdb
Match all files that end with.pdb
. (Done by the shell)(.d+)
Match a literal dot, then one or more decimal digits. The parens create a match group.$2$1
Reverse the first and second match groups.-n
No action (simulate). If the output looks good, run the command again without this flag.
1
LOL. Same thought. You were 48 seconds quicker.
â PerlDuck
Mar 29 at 16:02
1
@PerlDuck Lol, yeah, same thought. The answers complement quite well too: you cover installation, I cover syntax.
â wjandrea
Mar 29 at 16:04
@wjandrea ALWAYS run rename with-n
first.
â Calimo
Mar 30 at 8:59
@Calimo Good point. Edited to add that.
â wjandrea
Mar 30 at 21:13
add a comment |Â
up vote
10
down vote
up vote
10
down vote
Using Perl rename
:
rename -n 's/(.d+)(.pdb)/$2$1/' *.pdb
Quick explanation:
*.pdb
Match all files that end with.pdb
. (Done by the shell)(.d+)
Match a literal dot, then one or more decimal digits. The parens create a match group.$2$1
Reverse the first and second match groups.-n
No action (simulate). If the output looks good, run the command again without this flag.
Using Perl rename
:
rename -n 's/(.d+)(.pdb)/$2$1/' *.pdb
Quick explanation:
*.pdb
Match all files that end with.pdb
. (Done by the shell)(.d+)
Match a literal dot, then one or more decimal digits. The parens create a match group.$2$1
Reverse the first and second match groups.-n
No action (simulate). If the output looks good, run the command again without this flag.
edited Mar 30 at 21:12
answered Mar 29 at 15:59
![](https://i.stack.imgur.com/eVuAv.png?s=32&g=1)
![](https://i.stack.imgur.com/eVuAv.png?s=32&g=1)
wjandrea
7,18342255
7,18342255
1
LOL. Same thought. You were 48 seconds quicker.
â PerlDuck
Mar 29 at 16:02
1
@PerlDuck Lol, yeah, same thought. The answers complement quite well too: you cover installation, I cover syntax.
â wjandrea
Mar 29 at 16:04
@wjandrea ALWAYS run rename with-n
first.
â Calimo
Mar 30 at 8:59
@Calimo Good point. Edited to add that.
â wjandrea
Mar 30 at 21:13
add a comment |Â
1
LOL. Same thought. You were 48 seconds quicker.
â PerlDuck
Mar 29 at 16:02
1
@PerlDuck Lol, yeah, same thought. The answers complement quite well too: you cover installation, I cover syntax.
â wjandrea
Mar 29 at 16:04
@wjandrea ALWAYS run rename with-n
first.
â Calimo
Mar 30 at 8:59
@Calimo Good point. Edited to add that.
â wjandrea
Mar 30 at 21:13
1
1
LOL. Same thought. You were 48 seconds quicker.
â PerlDuck
Mar 29 at 16:02
LOL. Same thought. You were 48 seconds quicker.
â PerlDuck
Mar 29 at 16:02
1
1
@PerlDuck Lol, yeah, same thought. The answers complement quite well too: you cover installation, I cover syntax.
â wjandrea
Mar 29 at 16:04
@PerlDuck Lol, yeah, same thought. The answers complement quite well too: you cover installation, I cover syntax.
â wjandrea
Mar 29 at 16:04
@wjandrea ALWAYS run rename with
-n
first.â Calimo
Mar 30 at 8:59
@wjandrea ALWAYS run rename with
-n
first.â Calimo
Mar 30 at 8:59
@Calimo Good point. Edited to add that.
â wjandrea
Mar 30 at 21:13
@Calimo Good point. Edited to add that.
â wjandrea
Mar 30 at 21:13
add a comment |Â
up vote
7
down vote
You can use this script:
for i in `seq 1 2000`; do
mv file.$i.pdb file.pdb.$i
done
Or this copy-paste friendly command:
for i in `seq 1 2000`; do mv file.$i.pdb file.pdb.$i; done
For use above commands, put all 2000 files in one folder and then open terminal in that directory, then run above command in it.
add a comment |Â
up vote
7
down vote
You can use this script:
for i in `seq 1 2000`; do
mv file.$i.pdb file.pdb.$i
done
Or this copy-paste friendly command:
for i in `seq 1 2000`; do mv file.$i.pdb file.pdb.$i; done
For use above commands, put all 2000 files in one folder and then open terminal in that directory, then run above command in it.
add a comment |Â
up vote
7
down vote
up vote
7
down vote
You can use this script:
for i in `seq 1 2000`; do
mv file.$i.pdb file.pdb.$i
done
Or this copy-paste friendly command:
for i in `seq 1 2000`; do mv file.$i.pdb file.pdb.$i; done
For use above commands, put all 2000 files in one folder and then open terminal in that directory, then run above command in it.
You can use this script:
for i in `seq 1 2000`; do
mv file.$i.pdb file.pdb.$i
done
Or this copy-paste friendly command:
for i in `seq 1 2000`; do mv file.$i.pdb file.pdb.$i; done
For use above commands, put all 2000 files in one folder and then open terminal in that directory, then run above command in it.
edited Mar 29 at 15:51
answered Mar 29 at 15:44
![](https://i.stack.imgur.com/k7xZK.png?s=32&g=1)
![](https://i.stack.imgur.com/k7xZK.png?s=32&g=1)
Ali Razmdideh
3,18011436
3,18011436
add a comment |Â
add a comment |Â
up vote
5
down vote
Recently nautilus, the default file manager, received a batch rename dialog. It is not yet powerful enough to do what you want. But luckily there is thunar, an alternative file manager that can be installed. With thunars rename dialog you can do what you want using the GUI.
First install thunar:
sudo apt install thunar
Start thunar, navigate to the directory that has your files. Then select all of them. Press F2.
In the dialog that opens, again, select all files. Change mode to "Search & Replace" and to "Name & Suffix". Check "Regular Expression". Now use the following as search and replace patterns:
file.(.+).pdb
and
file.pdb.$1
Finally click the rename button.
The advantage of this way is that you get a visual preview of what will happen before you actually do the renaming.
1
You can make most programs print English messages by prefixing the command withLC_MESSAGES=POSIX
, e. g.LC_MESSAGES=POSIX free
. Works the same for graphical applications although in the case of persistent applications like Nautilus in its default configuration you need to terminate the previous instance withnautilus -q
first.
â David Foerster
Mar 30 at 16:00
@DavidFoerster thanks for mentioning, image replaced.
â Sebastian Stark
Mar 30 at 22:50
add a comment |Â
up vote
5
down vote
Recently nautilus, the default file manager, received a batch rename dialog. It is not yet powerful enough to do what you want. But luckily there is thunar, an alternative file manager that can be installed. With thunars rename dialog you can do what you want using the GUI.
First install thunar:
sudo apt install thunar
Start thunar, navigate to the directory that has your files. Then select all of them. Press F2.
In the dialog that opens, again, select all files. Change mode to "Search & Replace" and to "Name & Suffix". Check "Regular Expression". Now use the following as search and replace patterns:
file.(.+).pdb
and
file.pdb.$1
Finally click the rename button.
The advantage of this way is that you get a visual preview of what will happen before you actually do the renaming.
1
You can make most programs print English messages by prefixing the command withLC_MESSAGES=POSIX
, e. g.LC_MESSAGES=POSIX free
. Works the same for graphical applications although in the case of persistent applications like Nautilus in its default configuration you need to terminate the previous instance withnautilus -q
first.
â David Foerster
Mar 30 at 16:00
@DavidFoerster thanks for mentioning, image replaced.
â Sebastian Stark
Mar 30 at 22:50
add a comment |Â
up vote
5
down vote
up vote
5
down vote
Recently nautilus, the default file manager, received a batch rename dialog. It is not yet powerful enough to do what you want. But luckily there is thunar, an alternative file manager that can be installed. With thunars rename dialog you can do what you want using the GUI.
First install thunar:
sudo apt install thunar
Start thunar, navigate to the directory that has your files. Then select all of them. Press F2.
In the dialog that opens, again, select all files. Change mode to "Search & Replace" and to "Name & Suffix". Check "Regular Expression". Now use the following as search and replace patterns:
file.(.+).pdb
and
file.pdb.$1
Finally click the rename button.
The advantage of this way is that you get a visual preview of what will happen before you actually do the renaming.
Recently nautilus, the default file manager, received a batch rename dialog. It is not yet powerful enough to do what you want. But luckily there is thunar, an alternative file manager that can be installed. With thunars rename dialog you can do what you want using the GUI.
First install thunar:
sudo apt install thunar
Start thunar, navigate to the directory that has your files. Then select all of them. Press F2.
In the dialog that opens, again, select all files. Change mode to "Search & Replace" and to "Name & Suffix". Check "Regular Expression". Now use the following as search and replace patterns:
file.(.+).pdb
and
file.pdb.$1
Finally click the rename button.
The advantage of this way is that you get a visual preview of what will happen before you actually do the renaming.
edited Mar 31 at 13:16
answered Mar 30 at 10:10
![](https://i.stack.imgur.com/33gTl.jpg?s=32&g=1)
![](https://i.stack.imgur.com/33gTl.jpg?s=32&g=1)
Sebastian Stark
4,708938
4,708938
1
You can make most programs print English messages by prefixing the command withLC_MESSAGES=POSIX
, e. g.LC_MESSAGES=POSIX free
. Works the same for graphical applications although in the case of persistent applications like Nautilus in its default configuration you need to terminate the previous instance withnautilus -q
first.
â David Foerster
Mar 30 at 16:00
@DavidFoerster thanks for mentioning, image replaced.
â Sebastian Stark
Mar 30 at 22:50
add a comment |Â
1
You can make most programs print English messages by prefixing the command withLC_MESSAGES=POSIX
, e. g.LC_MESSAGES=POSIX free
. Works the same for graphical applications although in the case of persistent applications like Nautilus in its default configuration you need to terminate the previous instance withnautilus -q
first.
â David Foerster
Mar 30 at 16:00
@DavidFoerster thanks for mentioning, image replaced.
â Sebastian Stark
Mar 30 at 22:50
1
1
You can make most programs print English messages by prefixing the command with
LC_MESSAGES=POSIX
, e. g. LC_MESSAGES=POSIX free
. Works the same for graphical applications although in the case of persistent applications like Nautilus in its default configuration you need to terminate the previous instance with nautilus -q
first.â David Foerster
Mar 30 at 16:00
You can make most programs print English messages by prefixing the command with
LC_MESSAGES=POSIX
, e. g. LC_MESSAGES=POSIX free
. Works the same for graphical applications although in the case of persistent applications like Nautilus in its default configuration you need to terminate the previous instance with nautilus -q
first.â David Foerster
Mar 30 at 16:00
@DavidFoerster thanks for mentioning, image replaced.
â Sebastian Stark
Mar 30 at 22:50
@DavidFoerster thanks for mentioning, image replaced.
â Sebastian Stark
Mar 30 at 22:50
add a comment |Â
up vote
3
down vote
You can use rename
from util-linux
for this (the command is called rename.ul
in ubuntu):
rename.ul .pdb '' *
rename.ul "file." "file.pdb." *
This first removes the .pdb
extension from the end and then re-inserts it into the middle.
1
Pretty cool. I wasn't aware ofrename.ul
. The syntax is a bit, um, unexpected, but it actually works the way you advertise. Plus: it also has a-n
(don't touch, just tell) switch.
â PerlDuck
Mar 29 at 17:40
add a comment |Â
up vote
3
down vote
You can use rename
from util-linux
for this (the command is called rename.ul
in ubuntu):
rename.ul .pdb '' *
rename.ul "file." "file.pdb." *
This first removes the .pdb
extension from the end and then re-inserts it into the middle.
1
Pretty cool. I wasn't aware ofrename.ul
. The syntax is a bit, um, unexpected, but it actually works the way you advertise. Plus: it also has a-n
(don't touch, just tell) switch.
â PerlDuck
Mar 29 at 17:40
add a comment |Â
up vote
3
down vote
up vote
3
down vote
You can use rename
from util-linux
for this (the command is called rename.ul
in ubuntu):
rename.ul .pdb '' *
rename.ul "file." "file.pdb." *
This first removes the .pdb
extension from the end and then re-inserts it into the middle.
You can use rename
from util-linux
for this (the command is called rename.ul
in ubuntu):
rename.ul .pdb '' *
rename.ul "file." "file.pdb." *
This first removes the .pdb
extension from the end and then re-inserts it into the middle.
answered Mar 29 at 17:31
user812791
311
311
1
Pretty cool. I wasn't aware ofrename.ul
. The syntax is a bit, um, unexpected, but it actually works the way you advertise. Plus: it also has a-n
(don't touch, just tell) switch.
â PerlDuck
Mar 29 at 17:40
add a comment |Â
1
Pretty cool. I wasn't aware ofrename.ul
. The syntax is a bit, um, unexpected, but it actually works the way you advertise. Plus: it also has a-n
(don't touch, just tell) switch.
â PerlDuck
Mar 29 at 17:40
1
1
Pretty cool. I wasn't aware of
rename.ul
. The syntax is a bit, um, unexpected, but it actually works the way you advertise. Plus: it also has a -n
(don't touch, just tell) switch.â PerlDuck
Mar 29 at 17:40
Pretty cool. I wasn't aware of
rename.ul
. The syntax is a bit, um, unexpected, but it actually works the way you advertise. Plus: it also has a -n
(don't touch, just tell) switch.â PerlDuck
Mar 29 at 17:40
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1020310%2fhow-do-i-move-numbers-in-filenames-in-a-batch-renaming-operation%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e)
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom))
StackExchange.using('gps', function() StackExchange.gps.track('embedded_signup_form.view', location: 'question_page' ); );
$window.unbind('scroll', onScroll);
;
$window.on('scroll', onScroll);
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Didn't you mean bash?
â avazula
Mar 29 at 15:38
4
@avazula No please read this article : en.wikipedia.org/wiki/Batch_renaming
â Ali Razmdideh
Mar 29 at 15:47
@PerlDuck yes ;)
â Ali Razmdideh
Mar 29 at 15:52
6
Possible duplicate of How to easily rename files using command line?
â wjandrea
Mar 29 at 16:09
2
Hey close voters - do you all really think we only need one question in the [batch-rename] tag? Is there anything in the linked post that actually helps with the task in this question, except the idea of using
rename
? It seems to me that if a batch renaming question has specific details, we should just provide specific answers to it.â Zanna
Mar 31 at 9:41