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.

learn more… | top users | synonyms

1
vote
4answers
55 views

rename multiple files with mv

I want to rename a couple of files in the same directory. When you start to google this there is plenty of help available. What i saw the most if you only want to change the extension is mv *.txt ...
1
vote
1answer
26 views

Rename files based on directory names

How can I rename .jpg files in multiple folders based on the name of the folder? I also want the .jpg files to remain in their respective folders and not moved. The folder names have no spaces. So, ...
2
votes
2answers
31 views

Renaming files from prefix and sufix

I've a series of media files I'm trying to rename en mass. 001 - 01x01 - mediaTitle1.avi 002 - 01x02 - mediaTitle2.avi 003 - 01x03 - mediaTitle3.avi What I'd like is to output: Series Title S01 ...
1
vote
7answers
174 views

Remove a specific extension from all the files in a directory

I have a couple of files with ".old" extension. How can I remove the ".old" extension without remove the file? I can do it manually but with more work: mv file1.key.old file1.key mv ...
2
votes
2answers
57 views

How to rename thousands of files efficiently?

I have a bunch of music files (literally thousands of files) in my Fedora PC that I'd like to rename with two rules: Every space must be replaced by the character _ (underscore), and Every letter in ...
2
votes
4answers
92 views

Flattening folder structure

I have this folder structure: ├── foo1 │   ├── bar1.txt │   └── bar2.txt ├── foo2 │   ├── bar3.txt │   └── bar4 with a space.txt └── foo3 └── qux1 ├── bar5.txt └── bar6.txt that ...
3
votes
2answers
78 views

Atomic removal of directory

Because rename(2) is called by mv, is it safe to assume the following would be atomic? $ mv /home/me/someDir /tmp/toBeDeleted $ rm -rf /tmp/toBeDeleted
1
vote
4answers
101 views

Bash rename 360 000 files using find -exec

I've got around 360 000 files like: ./001/1/1.jpg ./001/1/2.jpg ./001/2/1.jpg ./002/1/1.jpg ./003/1/1.jpg ... pattern: [60 dirs]/[1000 subdirs]/[4-10 files].jpg I want to rename files using rename ...
5
votes
4answers
339 views

Remove next-to-last extension in a file name

Suppose a folder with many files with bad extensions,for example Song1.avi.mp3 Song2.avi.mp3 Song32.web.mp3 Song23.mp4.mp3 Song2a.mp9.mp3 I want to remove only the second field (web, avi, mp4). I ...
6
votes
2answers
137 views

renaming all files in all sub directories

How to rename all files in all sub directories, with the sub directories name and auto number. ex: parent -subdir --file.jpg --cat.jpg --dog.jpg rename to : parent -subdir --subdir_01.jpg ...
0
votes
2answers
107 views

how to rename multiple files by replacing string in file name? this string contains a “#”

How to replace a text string in multiple files in Linux How to rename multiple files by replacing word in file name? Replace string in files with certain file extension Searching a number of files ...
0
votes
1answer
48 views

Rename files in selected folder in Linux [duplicate]

Command for rename file as IMG0001 to 4R0001 in folder for f in *;do mv "$f" `echo "$f" | sed 's/IMG/4R/g' `; done AND I just want rename selected folder /tmp/2014/1201 (rename files) ...
3
votes
3answers
70 views

MMV mass file rename

I'm having trouble figuring an mmv pattern. I have a bunch of video files with this pattern: my.program.name.season.NN.episode.NN.-.title.avi and I need to move them to: ...
1
vote
2answers
84 views

How to rename file in bash script one by one

I have loads of files which look like this: data1.csv data2.csv . . data(n).csv My use case is that when I will call my script it will change data1.csv to data.csv and remaining files as it is and ...
1
vote
5answers
78 views

How to move a file and change its name without retyping the name and just add the new characters

I change too frequently the location of some files generated daily. The thing is that I want to change their names by only adding the new required characters. What I want is something like this: $ ...
1
vote
1answer
48 views

batch-rename all config file endings to conform to apache 2.4

since apache 2.4 all files in /etc/apache2/sites-available and sites-enabled have to be named with the ending .conf Now on my server I have a lot of these files, renaming the files in sites-available ...
0
votes
3answers
38 views

Replace occurrences of character in filenames [duplicate]

How can I replace all the occurrences of the + character in all the filenames in the current working directory with the space character? I know that there's the linux command rename but I'm not sure ...
2
votes
2answers
83 views

Rename files with even numbers

I have a collection of images which are scanned pages of books. They total some 10,000 pages. The books were printed bilingually, with the text and translation on facing pages. The translation has ...
0
votes
1answer
36 views

defining rename command scope; replace word; replace entire file name; wildcards

Im looking to use the rename command to edit file names. More specifically, Im trying to isolate specific pieces to change, or in some cases, the whole name. For example: Lets say I have three ...
1
vote
1answer
43 views

How to change double hyphen to single hyphen of file names?

I have been using the rename command to get control over my naming conventions across my system. In converting spaces in file names to hyphens, I have inadvertently created consecutive hyphens in some ...
1
vote
3answers
118 views

Add or subtract a number from the names of all the files in a directory

I have a number of png and jpg files whose names are numbers, e.g.0100.png, in a directory, How can I add 1 to their names, for example, to get 0002.png and 0003.png from 0001.png and 0002.png ...
1
vote
1answer
44 views

perl rename: Prepending something to a set of file names across subdirectories

Although perl's rename tool has become an invaluable companion for my daily work, there are still some quirks that make work more difficult - especially when files are not in current work directory. ...
6
votes
4answers
223 views

Strip Filenames and Rename

What rename command can I use which will delete the present filenames in a directory and replace them with alphanumeric filenames? Such as gg0001, gg0002, et cetera? And I'd like the command to work ...
0
votes
2answers
41 views

Rename multiple files [duplicate]

Preface: I am an absolute novice with Linux, please don't judge strictly. I have a directory containing several images (over 100) of a .pnm extension. I wish to rename them in such a sense, that ...
1
vote
1answer
65 views

Replace new lines char (^M) in all files and then rename file based on char string

I am not a UNIX guy but understand enough to gin up small scripts here and there except for this one where I may personally be not able to devote enough time. I have about 2000 files in a directory ...
4
votes
2answers
62 views

How to exchange words in a filename using the shell?

One of my customers is a school. On their file server all projects have a directory with the same naming scheme. <last name>, <first name> <second name>? - <project ...
0
votes
4answers
57 views

Bash multiple rename in one line: is possible?

Is possible to rename and substitute on fly with bash? for example i have VTS_01_1.VOB VTS_01_2.VOB VTS_01_3.VOB I want to rename for use in mencoder with movie_1.avi movie_2.avi,etc.. I ...
1
vote
3answers
64 views

How to rename multiple files by inserting numbers

I have a list of files like the following: pairs10_10.mp3 pairs10_11.mp3 pairs10_12.mp3 pairs10_13.mp3 pairs10_14.mp3 pairs10_15.mp3 pairs10_16.mp3 pairs10_17.mp3 pairs10_18.mp3 pairs10_19.mp3 ...
1
vote
2answers
598 views

scp with password and renaming the file [closed]

I need to execute scp command with renaming the file. I have tried with following code: HOST=lnx25 USERNAME=ngqa PASSWORD=xxxxx FILE=$1 FILE_NAME=`echo $FILE | awk 'BEGIN{FS="/"} {print $NF;}'` ...
1
vote
5answers
74 views

Rename a portion of multiple files

Take a number of files named: data_a_LT.fits data_a_LT.coo data_a_LT.ec data_a_LT.grp I want to replace all "a_LT" with "LT_A" such that I have: data_LT_A.fits data_LT_A.coo data_LT_A.ec ...
3
votes
2answers
201 views

zmv command to rename file after matching pattern

I was trying to figure out a solution for this question using zmv. I am unable to find an exact solution using zmv. This is what I could come up with so far. From here, I could rename all files like ...
5
votes
4answers
337 views

How to rename to fixed length

I have files named as 0-n.jpg for n from 1 to 500, for example. The problem is that some guy using Windows didn't use leading zeros so when I do ls I obtain 0-100.jpg 0-101.jpg ... 0-10.jpg ... ...
0
votes
1answer
45 views

How to remove a specific string from file name [duplicate]

I have a report running in UNIX and creating a file named xxxx_ddmmyy_hhmm_zzzzzz.txt. I need to remove the zzzzzz from the file name. How do I do it?
1
vote
3answers
142 views

rename hundreds of file by removing last few characters

I have hundreds of file andI want to remove last 7 characters from the filename but keeping its extension. Old name: abc_xyz12_4567.txt abcde_xyz12_4567.txt New name: abc_xyz.txt abcde_xyz.txt ...
4
votes
5answers
96 views

Rename Multiple files in unix

I have multiple files whose names look like this 2313_ABCDEAUG2014_PQRST_0_.pdf 3244_ABCDEAUG2014_PQRST_0_.pdf 4234_ABCDEAUG2014_PQRST_0_.pdf t want to rename the file in the following format. ...
1
vote
3answers
174 views

rename files with rename command

Please advice what is wrong with the following command find /tmp/dir -name "* *" -type f | rename 's/*/fixed_/g' remark - I prefer to do that with one command not loop syntax What I want is to ...
0
votes
3answers
103 views

rename a list of files according to a text file

I have a list of files in a folder, which I will like to rename according to a textfile. For example: These are the 5 files in the folder. 101_T1.nii 107_T1.nii 109_T1.nii 118_T1.nii 120_T1.nii I ...
2
votes
2answers
138 views

find file, copy but with different name

I have files with random numbers in /home/user/files folder (every 4 days I have new ones). for example: john20 john25 john40 tom12 tom32 simon2 simon8 simon53 I want to take only last modified ...
0
votes
2answers
98 views

change the extension of all files based on user input

I was taking an online assessment and I got the below question. Create a script located at /usr/local/bin/set-file-extensions that will change the extension of all files in the directory ...
1
vote
2answers
157 views

Rename a file dynamically containing spaces [duplicate]

I want to rename a file dynamically based on data which contains spaces Name="Abc DEF" Name1="GHI JKL" mv /sample/pdf/noriginalName.pdf /sample/outputPdf/${NAME}${Name1}".pdf" But it gives me an ...
0
votes
5answers
1k views

Move files to multiple folders [closed]

I've searched for this function, and there are lots of answers, but I haven't been able to find anything that works for me. I have a folder with about 30,000 files, and I want a terminal command or ...
4
votes
1answer
417 views

replace all dots in filenames with underscore

I have a directory with some subdirectories with filenames and directorynames that contain some dots: $ ls -R .: dir file.with.dots ./dir: subdir.with.dots ./dir/subdir.with.dots: other.file I ...
22
votes
3answers
3k views

How to rename file to .. (dot dot)?

Apparently you can rename file to .... If I were insane, how would I rename file to .. or .? Is such a filename even allowed? Backslash doesn't seem to disable dot's special meaning: $ mv test \. ...
6
votes
4answers
2k views

Delete spaces, hyphens, and underscores in filenames?

What is a good command to delete spaces, hyphens, and underscores from all files in a directory, or selected files? I use the following command with Thunar Custom Actions to slugify filenames: for ...
1
vote
1answer
44 views

Two HDD partitions with the same name result in uncertain directories

I'm running Ubuntu 14.04 on a machine that has a lot of hard drives plugged into it. These hard drives have partitions with old OS's which have a lot of key data that I use often. The problem is, I ...
4
votes
4answers
121 views

Renaming multiple files with rename

I need help renaming files in batch--the other questions I browsed don't exactly address my problem. The names of my files are generated non-deterministically, so I can't predict what they will be ...
1
vote
2answers
246 views

rename a batch of files after reading from a source file

I have a directory full of over a thousand files and the names are bit long (and no pattern found in the naming style). I would like to simplify the filenames. E.g.: ...
5
votes
3answers
602 views

How to remove dot and space from beginning of filenames

I'm trying to change jpg files named with a dot and a space at the beginning and with a missing dot before the end (like this . Startjpg to Start.jpg The dot makes the files hidden from sed and ls ...
1
vote
2answers
171 views

How would I change file permissions if the file name has a space in it in linux [duplicate]

I would like to know how would I rename and change file permissions of a file that contains a space in the name on Linux. Example The name of my file is: my file I have tried mv my%20file my_file ...
2
votes
1answer
79 views

Renaming the files and move to other path

I need to rename the files given below and move to some other path 1234551abcde20140718023216001.txt.809047512.2014_07_07_13:47:44 000001abcde20140718023216001.txt.34568.001.2014_07_07_13:50:44 ...