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

2
votes
2answers
76 views

Rename a set of files with pattern <name>.1.gz.html to <name>.html

I tried to use the command: mv *.1.gz.html *.html But, I got the response: <filename> is not a directory. How can I get this working? I tried the rename command as well, but, I couldn't ...
2
votes
1answer
29 views

Recursive copy files with rename

If I have input folder files_input that has subfilders like 01-2015, 02-2015, 03-2015 etc and all these subfolders have other subfolders. Each subfolder has only one file called index.html. How can ...
0
votes
1answer
27 views

Rename command not working as expected

I might be overlooking something really basic here but I have a bunch of files like fi-le_00.nc2 fi-le_01.nc2 fi-le_02.nc2 ... fi-le_24.nc2 and I want to rename them to fi-le_00:00:00 ...
-1
votes
1answer
87 views

mv command does not work in shell script [closed]

I want to rename a folder with a bash-script. I don't know why this command is not working in a shell script, but directly in the terminal is working without problems. ...some code... ...
4
votes
1answer
3k views

Using regex in ls and mv

I have a directory structure like this ├── UK │   ├── BuyBand_go_UK.png │   ├── BuyBand_go_UK.svg │   ├── BuyBand_K.png │   ├── BuyBand_K.svg │   ├── BuyBago_UK.png │   ├── BuyBago_UK.svg │   ├── ...
5
votes
2answers
126 views

Why does renaming a file with mv command alter an inode's “change” date & time?

A file hello.c is renamed to hi.c. As the output of stat command shows, [change] time stamp has been changed. usually it is changed when inode of file got modified. Why renaming with mv command ...
3
votes
3answers
129 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
30 views

How to add some characters to filename via 'rename'?

For example I have a file named 5.jpg. How can I rename it to aaaaa.jpg with char a 5 times. I tried rename -v 's/(\d{1,})/a{$1}/g' * but this renames 5.jpg to a{5}.jpg, which is not what I want. I ...
1
vote
4answers
59 views

Remove all brackets in filename

I've been trying to remove all brackets in my filename(s). Can anyone help me create a bash script to do that? This bash script below work flawlessly for non-bracket filename(s), but if there are any ...
10
votes
4answers
7k views

How can I rename photos, given the EXIF data?

Let's say I have a bunch of photos, all with correct EXIF information, and the photos are randomly named (because of a problem I had). I have a little program called jhead which gives me the below ...
1
vote
3answers
94 views

Script to move one filetype and create a subfolder, if it exists?

I'm trying to find a script that would basically look recusively at a directory, and if the script finds file that are .flac files, it will create a subfolder called FLAC in that same folder, and move ...
4
votes
2answers
810 views

Renaming files in lexicographical order with a numerical pattern that increases sequentially with fixed padding

I have files such as a bb ccc abc emrls I would like to rename them so that, after sorting them (for example, lexicographically), each file gets the following name: 00001 00002 00003 etc where ...
2
votes
4answers
3k views

move file by list in file

I have a file that contains file names. For example: /tmp/list.txt (it is with the spaces at the start of each line): /tmp/file.log /app/nir/home.txt /etc/config.cust I want, using one ...
18
votes
4answers
38k views

Move folder content up one level

I have a directory that is unpacked, but is in a folder. How can I move the contents up one level? I am accessing CentOS via SSH.
3
votes
4answers
9k views

How to rename multiple files by removing the extension?

I have a number of tiff files named: sw.001.tif sw.002.tif ... and I want to remove the .tif at the end of each of the files. How can I use the rename command to do this?
3
votes
3answers
80 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
159 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
290 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
56 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
63 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
52 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 ~
4
votes
4answers
73 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 ...
3
votes
7answers
137 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
76 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 ...
8
votes
1answer
2k views

zmv for zsh: Dry runs and man pages

I've heard great things about zmv in zsh, and would love to really learn to use it. However, I am still relatively unexperienced in zsh, and have some basic questions: Is there is a man page for zmv ...
1
vote
4answers
422 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 ...
1
vote
1answer
45 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 ...
6
votes
4answers
297 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 ...
10
votes
4answers
17k views

How can you move (or copy) all files of a certain type to a directory in Unix?

I'm not very familiar with all the tricks of grep/find/awk/xargs quite yet. I have some files matching a particular pattern, say *.xxx. These files are in random places throughout a certain ...
5
votes
2answers
273 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
47 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 ...
1
vote
2answers
115 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 ...
9
votes
2answers
5k views

Why can't I have a folder and a file with the same name?

I've never had this problem before, but for some reason, I can't rename my folder to packages/. This is the structure: root - packages_old/ - packages When I try to rename the folder with ...
8
votes
1answer
4k views

Command-line mv exclusion list

Is there a way to mv,cp, or any file operation such that I could specify all the files I don't want affected? For example, say I have a folder with the files file1, file2, and file3, and I want to ...
-1
votes
1answer
46 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 ...
1
vote
1answer
52 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 ...
5
votes
4answers
1k views

How to remove URI encoding from file names?

I realise this might be quite a simple question, but I'm still quite new to the command line and only have a grasp of basic commands. I've downloaded some lecture presentations (~25 or so) from my ...
1
vote
3answers
46 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
3answers
43 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
109 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 ...
2
votes
4answers
274 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 ...
1
vote
2answers
108 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 ...
2
votes
1answer
40 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
1answer
90 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
0answers
49 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 ...
5
votes
5answers
141 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
0answers
88 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 ...
3
votes
3answers
119 views

Moving an open file to a different device

I have an application running that is generating a large (~200GB) output file, and takes about 35 hours to run (currently I'm about 12 hours in). The application just opens the file once then keeps it ...
2
votes
3answers
151 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 ...
2
votes
1answer
463 views

Can I get the backup option of cp and mv to work with directories?

--backup[=CONTROL] make a backup of each existing destination file The man page does say that it works on file. It doesn't seem to have any effect on directories. Is there anyway to make this ...