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

3
votes
3answers
58 views

How to change suffix of the files

In a directory structure which has multiple subfolders and files in it. Some of the file names have the suffix _create (e.g. java1_create) and some of them with _bak (java2_bak). I need to rename ...
2
votes
3answers
145 views

Add extension for multiple files, based on their types

I know that there are many questions about adding extension to a multiple files. But none of them could get my job done. I have a huge list of images without extension, most of them are png, but ...
4
votes
4answers
217 views

How can I copy a file in a bash script and rename it while copying and place it in the same directory

How would I copy a file "file.doc" and rename it while copying to "file_copy.doc" and place it in the same directory ? And this only by calling the script and adding the file name in the argument: ...
0
votes
5answers
51 views

same file name in multiple directories: how to assign them with different names at the same time with only one command?

I think the title is self-explanatory, but my problem is: I have 23 different directories and in each one of them I have a file called accepted_hits.bam so I need to generate a unique name in each ...
1
vote
2answers
45 views

Remove string from file name to leave variable?

I have the following list of files: Dorn_Triatomine_A5201_sequence_1_unmappedforTdim_tdim.alleles.tsv Dorn_Triatomine_A5201_sequence_1_unmappedforTdim_tdim.matches.tsv ...
0
votes
3answers
50 views

Remove trailing ~ from files [closed]

I have a list of files ending with ~ I find them with find /var/www/vhosts/domain.com/httpdocs/ -type f -name "*.*~" How can I eliminate that ~
3
votes
7answers
125 views

find files based on name and moving them with renaming simultaneously

Consider I've directories named according to years and containing pdf files according to subject-code. ls output is: $ ls -l total 32 drwxrwxrwx 1 root root 4096 Apr 8 08:52 May-June-2011 ...
1
vote
3answers
68 views

Rename files (delete some characters that are not always the same)

I have some files named like this : DA1_ATGCATG_L001_R1.fastq.gz Oeu43_TCATGAC_L004_R2.fastq.gz I want to delete the part after the first "_" but keep the end of the names from "_R" to obtain this ...
1
vote
1answer
31 views

How to change configuration of detox (dash instead underscore)?

I found, best to this moment, a solution when changing all those annoying filenames in large quantities, making them readable and easier to manipulate with in command-line. So I found, among many ...
5
votes
2answers
251 views

cannot rename files with `[ ]` on its name?

I'd been trying to use the rename function in my debian, I searched here at unix.stackexchange but it seems the solution is not the same in my scenario which files contains [] ...
1
vote
1answer
26 views

File corruption using rsync, multiple rsync processes, moved/renamed source file

I'm encountering some file corruption when using rsync (that is, the file contents do not match the source file). I can understand the file becoming corrupt if it is being written to while being ...
2
votes
3answers
114 views

remove all instances of _000 from multiple files

Had to recover my music library from a HDD which died.... got everything I wanted but all music track names have _000 added at the end. I really don't fancy going through 8000 individual music tracks ...
1
vote
2answers
93 views

Mac Terminal - rename *.png.png to *.png

I have a bunch of images that I'd like to rename as follows: *.png.png --> *.png *.jpeg.jpg --> *.jpg *.JPEG --> *.jpg The only thing I've tried thus far is mv *.png.png *.png, but I knew ...
3
votes
4answers
67 views

Traverse, copy & transform file names

My issue: I need to copy log files, all with identical names, but stored 1-deep in subdirectories, and change their names. I'm copying from the a folder called Logfiles which contains a bunch of ...
-1
votes
1answer
29 views

Copy files from find command [closed]

I am trying to copy all *file.log files found using find. The problem is all files are named the same and it is only copying over one file. I need to find a way to rename the files in the command or ...
2
votes
3answers
40 views

Rename multiple files to their suffixes

I need a way to rename a couple of files containing spaces. I have: >ls Garbage Foo1.txt Garbage Foo2.txt Garbage Foo3.txt Garbage Foo4.txt ... And I need: Foo1.txt Foo2.txt Foo3.txt Foo4.txt ...
2
votes
4answers
98 views

Add 0 in the middle of a filename

$ ls pro2e_u01_txt_vocabulaire_11_descriptiveadjectives.mp3 pro2e_u01_txt_vocabulaire_12_nationality.mp3 pro2e_u01_txt_vocabulaire_1_campus.mp3 pro2e_u01_txt_vocabulaire_2_personnes.mp3 ...
1
vote
1answer
48 views

Renaming multiple files; appending

I'm looking to rename multiple files with the same name, with exception to the end of their file names. I want to replace the differing parts with an incremental counter. E.g. With the following ...
1
vote
3answers
42 views

How to mass rename files with ill-formed numbering?

I've got bunch of files with ill-formed numbering: prefix-#.ext | for files with number 1-9 prefix-##.ext | for files with number 10-99 prefix-###.ext | for files with number 100-999 ...
2
votes
1answer
35 views

Copy files that partially matches another files in another location

I have a list of jpeg files in a directory like this (below is just a sample, like the structure is the same but this there are many fo0# sub-folders, not only fo01 and fo01, where each of these ...
2
votes
4answers
197 views

Creating directories in a loop and moving files to those directories

Consider a directory with N files. I can list the files alphabetically sorted and store the list by ls > list Then I want to create n sub-directories in same directory, which can be done by ...
2
votes
1answer
55 views

Remove newlines in file names

I have a PHP code that generates the file name on which wget will append its logs. I generated 2000+ files, but the problem is I am having trouble working with them because I had a mistake of putting ...
1
vote
2answers
72 views

Rename files depending on their parent directory

I have a main directory, let's say main. This main directory has some folders, among which are three folders named ccc ddd and lll, which are the only folders I want to target and work on. Each of ...
1
vote
0answers
35 views

Automatically Rename File if there's a Duplicate Filename

I have a command that creates montages of images. Sometimes I want to save multiple montages from a series of images in a folder. The montage will be saved as output.jpg. But if I create another ...
1
vote
0answers
66 views

How to rename file and folder of mp3 based on ID3 tag

How to rename music files based on ID3 tag with format: number. title where the number doesn't exists on the id3tag but exists on the file name? And how to rename folders based on ID3 tag with format ...
0
votes
3answers
49 views

Change Multiple (Including No) File Extensions

If I have a directory of files, where some files have an extension like .html and some files have no extension, how do I change them all to, e.g. .txt?
2
votes
3answers
100 views

Copy files to a destination folder only if the files already exist. but the source files have a different file extension

Copy files to a destination folder only if the files already exist. but the source files have a different file extension. i.e I have a backup of some files with ".desktop.in" extension and I want to ...
17
votes
2answers
931 views

Renaming the current directory from a shell - possible?

Is it possible to rename the current working directory from within a shell (Bash in my particular case)? If I attempt to do this the straightforward way, I end up with an error: ...
1
vote
1answer
43 views

Batch rename “case duplicates”

I have a folder on my Linux system that is cross-synchronized with other computers, some of them with Windows. The problem is that in that folder there are files that are "case duplicates", i.e. their ...
0
votes
3answers
52 views

Renaming multiple Files, Bash Script, preferably with an Addition

Hello you wonderful people, I have a little problem creating a Bash Script. I have 7000 image files (dicoms). These files belong together and should be in order in ONE directory. However, the program ...
1
vote
1answer
92 views

Swap two files in bash [duplicate]

How do I swap two files in Linux console with minimum typing? Boring approach: $ mv file1.dat fileX.dat $ mv file2.dat file1.dat $ mv fileX.dat file2.dat
1
vote
1answer
19 views

Rename command with non-existing target directory

I'm trying to group files automatically into subdirectories using a command like this: $ rename 's/(.)(.)(.+)/$1\/$2\/$1$2$3/' *.* A dry run with the -n parameter shows me what I want: test.jpg ...
0
votes
1answer
103 views

rename multiple files with one variable

I am trying to rename one file with one variable. Example: 2014.001.**.**.**.D890.E.m to IP.PMST..BHE.D.2014.001. My script is: #!/bin/bash cd /home/pintolcv/Downloads for jd in {001..366} do ...
-1
votes
1answer
28 views

Rename multiple file with no extensions? [duplicate]

I have multiple files all named seperate1 seperate2 etc. How do I rename them all to have the extension .csv?
0
votes
2answers
82 views

Rename file by it is folder name

I have a sort of folders (A,B,C,D,E,F,G,H) and I have one file in every folder has the same name in all the folders (file.txt) but the size of this file is different from folder to folder. I wanted to ...
1
vote
4answers
1k 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
252 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
45 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
313 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
126 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
135 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
108 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
848 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
417 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
160 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
1k 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
90 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
101 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
137 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
119 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: $ ...