Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

rename(1) [centos man page]

RENAME(1)							   User Commands							 RENAME(1)

NAME
rename - rename files SYNOPSIS
rename [options] expression replacement file... DESCRIPTION
rename will rename the specified files by replacing the first occurrence of expression in their name by replacement. OPTIONS
-v, --verbose Give visual feedback which files where renamed, if any. -V, --version Display version information and exit. -s, --symlink Peform rename on symlink target -h, --help Display help text and exit. EXAMPLES
Given the files foo1, ..., foo9, foo10, ..., foo278, the commands rename foo foo0 foo? rename foo foo0 foo?? will turn them into foo001, ..., foo009, foo010, ..., foo278. And rename .htm .html *.htm will fix the extension of your html files. WARNING
The renaming has no safeguards. If the user has permission to rewrite file names, the command will perform the action without any ques- tions. For example, the result can be quite drastic when the command is run as root in the /lib directory. Always make a backup before running the command, unless you truly know what you are doing. SEE ALSO
mmv(1), mv(1) AVAILABILITY
The rename command is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/. util-linux June 2011 RENAME(1)

Check Out this Related Man Page

RENAME(1)						 Perl Programmers Reference Guide						 RENAME(1)

NAME
rename - renames multiple files SYNOPSIS
rename [ -v ] [ -n ] [ -f ] perlexpr [ files ] DESCRIPTION
"rename" renames the filenames supplied according to the rule specified as the first argument. The perlexpr argument is a Perl expression which is expected to modify the $_ string in Perl for at least some of the filenames specified. If a given filename is not modified by the expression, it will not be renamed. If no filenames are given on the command line, filenames will be read via standard input. For example, to rename all files matching "*.bak" to strip the extension, you might say rename 's/.bak$//' *.bak To translate uppercase names to lower, you'd use rename 'y/A-Z/a-z/' * OPTIONS
-v, --verbose Verbose: print names of files successfully renamed. -n, --no-act No Action: show what files would have been renamed. -f, --force Force: overwrite existing files. ENVIRONMENT
No environment variables are used. AUTHOR
Larry Wall SEE ALSO
mv(1), perl(1) DIAGNOSTICS
If you give an invalid Perl expression you'll get a syntax error. BUGS
The original "rename" did not check for the existence of target filenames, so had to be used with care. I hope I've fixed that (Robin Barker). perl v5.14.2 2014-09-26 RENAME(1)
Man Page

15 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

batching files

HI, Suppose I have thousand files in one directory and they can keep increasing ie /home/rooh Then I want to create a batch of 100 files and then compress that batch file and ftp them somewhere else. And morever the files in the batch will be moved to somewhere else. Can you please help... (21 Replies)
Discussion started by: rooh
21 Replies

2. UNIX for Dummies Questions & Answers

Easy way to mass rename files?

Hi. What is the easiest way to rename a bunch of files? For example taking all files ending in ".php3" and rename them to end in ".php" I could write a script to do this, but there is probably an easier way... Thanks! (17 Replies)
Discussion started by: Thermopylae
17 Replies

3. UNIX for Dummies Questions & Answers

Shell command?

I'm trying to reset my MySQL password in Terminal (OSX user) and am feeling my way through the process, as I know very little Unix. The guide I'm using suggests the following command as the final step: shell> mysqld_safe --init-file=~/mysql-init & to which Terminal responds (when I do it)... (12 Replies)
Discussion started by: tmallen
12 Replies

4. Shell Programming and Scripting

Renaming the files

Hello, i wanna rename my files which names are written in movies.txt films.txt = amovie bmovie cmovie dmovie emovie and i wanna find this files and rename the files to 1_amovie ... (12 Replies)
Discussion started by: redbeard_06
12 Replies

5. Shell Programming and Scripting

rename multiple files

Hi, can anyone have a ksh script to rename multiple files (ie to remove .Z extension of the files) can someone correct this? for i in *.Z do var1 = substr($i, 1,at(".Z",$i)-1) mv $i $var1 done Thanks.. Antony (13 Replies)
Discussion started by: antointoronto
13 Replies

6. Shell Programming and Scripting

Grep and rename the filename

Hi All, Can you please help me. The situation is like this. There are many different file name in this directory. I have to grep all the file that the name start with "PTWO" and rename it to COM with the current date. This is the script that I have done and it hit an... (16 Replies)
Discussion started by: badbunny9316
16 Replies

7. Programming

compile fails in linux ... "No rule to make target" ... HELP

hello all, attached you can find a tool (written in C) that i really need to make it compile under linux i am able to compile and run it successfully in mac os x, but in linux the compilation fails the only thing that i did so far is to change the following #include <sys/malloc.h> to... (13 Replies)
Discussion started by: OneDreamCloser
13 Replies

8. Shell Programming and Scripting

renaming multiple files

I have to rename 100+ files at a time on the server & was trying to use a script for doing that. I have used ultra edit to create a file having current filename & new file name as below file234.txt | file956.txt file687.txt | file385.txt There is no fixed pattern while renaming & would... (20 Replies)
Discussion started by: crux123
20 Replies

9. Shell Programming and Scripting

Unix How to combine find and cp

Hi ,i want to find sertain files and copy them with cp in current folder (16 Replies)
Discussion started by: lio123
16 Replies

10. UNIX for Dummies Questions & Answers

Renaming files in one file from names in other

Hi Guys, I have a small problem of renaming multiple files. For example I have names of a set of files in one directory like K2_34625-34675 K7_988963-988983 K12_773882-7734102 and the other set corresponding to the same is U_P_321_9_3_11.ab1 U_P_322_9_3_11.ab1 U_P_323_9_3_11.ab1 Now... (23 Replies)
Discussion started by: pawannoel
23 Replies

11. Linux

Setting up crontab, still cant get it to work

OK I have been working on this simple action for a while and I cannot get it to work. First off im new to the linux command line world. I feel like I am missing something simple. What I am trying to achieve is that I want this command: tcpdump -s2000 -w'flowroute-%H%M.pcap' -G900 -W36 &to... (13 Replies)
Discussion started by: Nasasdge
13 Replies

12. Linux

Ambiguous redirect error and syntax error when using on multiple files

Hi, I need help on following linux bash script. When I linux commands for loop or while loop on individual file it runs great. but now I want the script to run on N number of files so it gives me ambiguous redirect error on line 12 and syntax error on line 22 : (pls help ); #!/bin/bash #... (16 Replies)
Discussion started by: Madhusudan Das
16 Replies

13. Shell Programming and Scripting

Quick script to rename files

so I have about 30k jpg files that I need to rename in one hit. The current filename format is: x_surname_firstname_y_20141115_OS_(z) where x, y and z are numbers of various lengths the new filename format needs to be surname_firstname_y_OS_(z) So I basically need to remove the first... (23 Replies)
Discussion started by: jonesal2
23 Replies

14. Shell Programming and Scripting

Parse multiple html files in directory

I have downloaded source code for 97 files using: wget -x -i link.txt then run a rename loop: for file in * do mv $file $file.txt done to keep the html tags but make the file a text that can be parsed. In each of the 97 txt files the gene # is variable, but the gene is associated... (15 Replies)
Discussion started by: cmccabe
15 Replies

15. Shell Programming and Scripting

Rename file using partial match to another

In the below I am trying to rename the contents within each data subfolder in a specific run, based on a partial match of the IonCode_0000_ in each file in the data subdirectory to $1 in f1. There will be multiple runs in f1 but each run in $uniq is unique and will be found in f1 and the rename... (27 Replies)
Discussion started by: cmccabe
27 Replies