Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

rename(1) [v7 man page]

RENAME(1)						     Linux Programmer's Manual							 RENAME(1)

NAME
rename - Rename files SYNOPSIS
rename from to file... rename -V DESCRIPTION
rename will rename the specified files by replacing the first occurrence of from in their name by to. -V, --version Display version information and exit. For example, 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. SEE ALSO
mmv(1), mv(1) AVAILABILITY
The rename command is part of the util-linux-ng package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux-ng/. 1 January 2000 RENAME(1)

Check Out this Related Man Page

RENAME(3)								 1								 RENAME(3)

rename - Renames a file or directory

SYNOPSIS
bool rename (string $oldname, string $newname, [resource $context]) DESCRIPTION
Attempts to rename $oldname to $newname, moving it between directories if necessary. If $newname exists, it will be overwritten. PARAMETERS
o $oldname - Note The old name. The wrapper used in $oldname must match the wrapper used in $newname. o $newname - The new name. o $context - Note Context support was added with PHP 5.0.0. For a description of contexts, refer to "Streams". RETURN VALUES
Returns TRUE on success or FALSE on failure. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.1 | | | | | | | rename(3) can now rename files across drives in | | | Windows. | | | | | 5.0.0 | | | | | | | rename(3) can now also be used with some URL | | | wrappers. Refer to "Supported Protocols and Wrap- | | | pers" for a listing of which wrappers support | | | rename(3). | | | | | 4.3.3 | | | | | | | rename(3) may now be able to rename files across | | | partitions on *nix based systems, provided the | | | appropriate permissions are held. Warnings may be | | | generated if the destination filesystem doesn't | | | permit chown() or chmod() system calls to be made | | | on files -- for example, if the destination | | | filesystem is a FAT filesystem. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 Example with rename(3) <?php rename("/tmp/tmp_file.txt", "/home/user/login/docs/my_file.txt"); ?> SEE ALSO
copy(3), unlink(3), move_uploaded_file(3). PHP Documentation Group RENAME(3)
Man Page

15 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Need help with Interactive rename file.

hey all i was writing a script to 1. Rename a file upon the user's request. If the file exists, prompt the user for confirmation before renaming the file. The screen should prompt the user for a. “Name of file you want to rename.” Use the “\c” escape character. b. ... (36 Replies)
Discussion started by: keyboardkowboy
36 Replies

3. 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

4. Shell Programming and Scripting

Need help for a Shell script to rename multiple files

Hi! I need help to create a shell script to search inside a file and then copy a portion of the search result as the new file name. Basically I was hacked over the weekend and the genius wipe out my drive from my server. I was able to recover alot of files, but biggest problem Is now the... (15 Replies)
Discussion started by: kidney514
15 Replies

5. Shell Programming and Scripting

Rename file using sed command

Greetings, I am very new to the UNIX shell scripting and would like to learn. However, I am currently stuck on how to process the below sample : Filename : DOCabcdef24387987ab90d.xml Pattern "DOC"+any character using and +".xml" And i want to change the second part of that file (any... (20 Replies)
Discussion started by: fanny_tirtasari
20 Replies

6. UNIX for Advanced & Expert Users

Critical lib renamed

Hello I have moved a critical lib from its location, so all programms linked to libc dont work . I still have two shells on the machine, bash and ksh The only thing I see is copying back the lib, but of course : dd, cp , mv etc are dead . So i tryed a loop with read ... {^Jwhile read... (24 Replies)
Discussion started by: remi75
24 Replies

7. Solaris

Renamed lib directory by mistake

Let's say someone accidentally renamed the lib directory in Solaris 8, and now they cannot get into the terminal or even rename the folder via file manager.What would one do? (37 Replies)
Discussion started by: jetjaguar
37 Replies

8. Shell Programming and Scripting

How best to remove certain characters from filenames and folders recursively

hello, I'm trying to figure out which tool is best for recursively renaming and files or folders using the characters \/*?”<>| in their name. I've tried many examples that use Bash, Python and Perl, but I'm not much of a programmer I seem to have hit a roadblock. Does anyone have any... (15 Replies)
Discussion started by: prometheon123
15 Replies

9. Shell Programming and Scripting

Rename file using sed or awk

I have a filename like 1_DATE_3_4.5_888 and I want to modify the date field (ie the last 4 digits ) alone and remove the last field. Old filename:1_DATE_3_4.5_888 Given date (for eg):120606259532 modified date:120606259899 new filename:1_<modified date>_3.4.5 (14 Replies)
Discussion started by: sandy88
14 Replies

10. Shell Programming and Scripting

Renaming by manipulating strings

hello does someone want to help me for this one ? i want to rename file by inversing parts of filenames separated by the delimiter "--" sometimes filenames have three strings : aabb4ccdd eeffgg -- 5566 -- aa78bb ccd eef gghhi.ext to aa78bb ccd eef gghhi --... (17 Replies)
Discussion started by: mc2z674gj
17 Replies

11. Shell Programming and Scripting

Rename folder

hi guys i have a group of directory like these p1( 15 - 16 ) p2( 17 -15 ) p1 ( 14 - 20 ) p2 ( 13 -17 ) .. . . directories contain numbers represent time i want to rename all directories and change all numbers in directories' name . for example p1( 15 -16 ) will change to... (16 Replies)
Discussion started by: mhs
16 Replies

12. 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

13. UNIX for Beginners Questions & Answers

Use portion of file name as new file name

Hello, This is my first posting and attempt to create a loop using Unix and awk commands. So far this is what I have: awk -F, 'BEGIN {months ="AP01"; months ="AP02"; months ="AP03"; months ="AP04"; months ="AP05"; months ="AP06"; months ="AP07"; months ="AP08"; months ="AP09"; months... (25 Replies)
Discussion started by: Raul_Rodriguez
25 Replies

14. UNIX for Beginners Questions & Answers

Split and Rename Split Files

Hello, I need to split a file by number of records and rename each split file with actual filename pre-pended with 3 digit split number. What I have tried is the below command with 2 digit numeric value split -l 3 -d abc.txt F (# Will Produce split Files as F00 F01 F02) How to produce... (19 Replies)
Discussion started by: techedipro
19 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