Questions tagged [rename]
The rename tag refers to the action of giving a different name to either an existing file or to a copy of a file as part of some other operations (.e.g. remote copy, backup). Use this tag as well for questions related to the (perl) rename command.
1,231 questions
4
votes
3
answers
476
views
how to set an initial value when batch renaming to sequential numbering?
In this answer, the command
rename -n 'our $i; s/_.*/sprintf("_%03d.png", $i++)/e' *.png
is used to rename the files
abc_128390.png
abc_138493.png
abc_159084.png
...
to
abc_001.png
abc_002....
6
votes
2
answers
316
views
Recursively rename folders removing underscore and every character after
I have hundreds of folders in the following format
Foldername45_12345
I'd like to recursively rename them so they are in this format
Foldername45
I've been manually doing this over sftp but would ...
3
votes
2
answers
279
views
How can 'rename' be used to rename file in a specific directory?
I need to rename a part of a Java JAR file and I need to keep the version numbers in the filename:
Original file: hello-service-0.1.0.jar
Expected file: hello-my-service-0.1.0.jar
The following ...
1
vote
0
answers
74
views
rename "Duplicate specification" for option error
The other day something started going wrong with the perl rename terminal command that was pre-installed on my system; which is Ubuntu 22.04.5 LTS. When I try to use any version of the rename command ...
0
votes
5
answers
212
views
Rename a set of files according to a specific scheme, with rename back option
In Linux in a directory there are files, ls -1 shows me this output :
file1.1-rvr
file1.2-rvr
file1.3
file1.4-rvr
file1.5
file1.6-rvr
file2.1
file2.2
file3.1
file3.10
file3.2-rvr
file3.3-rvr
file3.4
...
0
votes
1
answer
49
views
Rename any number of archives within a directory under a condition [duplicate]
I'm using ubuntu linux and have huge folders of .pdf or .odt even sometimes .zip (or sometimes other formats however the first two are the most common). To access them through the command shell easily ...
5
votes
6
answers
2k
views
Why can't I merge folders by renaming one of them?
Try to run this
mv -- "foldername...__" "foldername..."
This will move folder foldername...__ under the folder foldername... instead of renaming it. Why?
Note that foldername... ...
8
votes
4
answers
2k
views
Why do my UTF-8 filenames always match against a regex bracket expression in Perl?
Here is a script to fix broken Cyrillic filenames if the files were moved to Mac from Windows (based on an answer to Revert filenames after they were garbled by using different encoding)
#!/bin/zsh
# ...
1
vote
3
answers
94
views
Duplicate and rename files with matching names but different extensions in bash?
Is there some simple way to duplicate both .cpp and .h files (or any multitude of extensions) simultaneously in bash, instead of:
cp foo.cpp bar.cpp
cp foo.h bar.h
I'm not looking for shell script ...
0
votes
1
answer
80
views
Is there a tool to "recursively" move/rename a directory (with conflicts/merging)?
Imagine I want to move (rename) a directory tree /var/lib/postgres/data to /var/lib/postgres/data.old:
/var/lib/postgres
└── data
├── base
│ ├── 16390
│ │ └── <...>
│ └── ...
0
votes
0
answers
62
views
Rename multiple files (bulk rename) disabled in MATE v: 1.26.2 (marco v: 1.26.2) on Linux Mint 22 (Wilma)
Before my last system upgrade, I enjoyed the functionality of renaming multiple files in the system GUI file manager (I use Marco in MATE).
This is also called "bulk rename", e.g. here.
...
3
votes
1
answer
263
views
Replace accented characters with perl-rename
I'm standardizing the name of several files at once, so I wrote a regex for perl-rename:
perl-rename 'y/A-Z/a-z/; s/ã|á|â/a/g; s/é|ê/e/g; s/í/i/g; s/õ|ó/o/g; s/ú/u/g; s/ç/c/g; s/(?<=\d-)*\s/_/g; s/...
0
votes
0
answers
100
views
I accidentally rename lib/ld-linux-aarch64.so.1 file on my target machine, what should i do?
I accidentally renamed ld-linux-aarch64.so.1. Now I cannot connect my target machine with SSH. How can I rename it back? I will not consider to reflash my target machine.
1
vote
1
answer
103
views
Several rename commands in shell script [closed]
Trying to figure out how to include several rename commands in one shell script that I will save as a cron job.
What I would like to accomplish is renaming different words and also suppress error ...
0
votes
2
answers
328
views
To batch rename files so that spaces will be replaced with underscores
Is it possible to batch rename files in Fish so that the spaces will be replaced with underscores?
I tried to figure it out myself, but haven't succeeded yet: https://fishshell.com/docs/current/cmds/...