]>
Commit | Line | Data |
---|---|---|
eb63b9b8 KZ |
1 | .\" Written by Andries E. Brouwer (aeb@cwi.nl) |
2 | .\" Placed in the public domain | |
3 | .\" | |
232dc924 | 4 | .TH RENAME 1 "June 2011" "util-linux" "User Commands" |
eb63b9b8 | 5 | .SH NAME |
0791a058 | 6 | rename \- rename files |
eb63b9b8 | 7 | .SH SYNOPSIS |
f736d385 | 8 | .B rename |
f49ccec2 BS |
9 | [options] |
10 | .IR "expression replacement file" ... | |
eb63b9b8 KZ |
11 | .SH DESCRIPTION |
12 | .B rename | |
13 | will rename the specified files by replacing the first occurrence of | |
03b3d715 | 14 | .I expression |
eb63b9b8 | 15 | in their name by |
03b3d715 SK |
16 | .IR replacement . |
17 | .SH OPTIONS | |
2a45745f | 18 | .TP |
7ab71099 BS |
19 | .BR \-s , " \-\-symlink" |
20 | Do not rename a symlink but its target. | |
03b3d715 | 21 | .TP |
7ab71099 | 22 | .BR \-v , " \-\-verbose" |
deff4975 | 23 | Show which files were renamed, if any. |
03b3d715 | 24 | .TP |
f60d62af | 25 | .BR \-n , " \-\-no\-act" |
990bf1f0 AR |
26 | Do not make any changes. |
27 | .TP | |
f60d62af KZ |
28 | .BR \-o , " \-\-no\-overwrite" |
29 | Do not overwrite existing files. | |
30 | .TP | |
7ab71099 BS |
31 | .BR \-V , " \-\-version" |
32 | Display version information and exit. | |
5a2a8177 | 33 | .TP |
7ab71099 | 34 | .BR \-h , " \-\-help" |
449a215f | 35 | Display help text and exit. |
0791a058 BS |
36 | .SH EXAMPLES |
37 | Given the files | |
eb63b9b8 KZ |
38 | .IR foo1 ", ..., " foo9 ", " foo10 ", ..., " foo278 , |
39 | the commands | |
eb63b9b8 | 40 | .RS |
03b3d715 | 41 | .PP |
eb63b9b8 | 42 | .nf |
ed21c47a | 43 | rename foo foo00 foo? |
eb63b9b8 KZ |
44 | rename foo foo0 foo?? |
45 | .fi | |
03b3d715 | 46 | .PP |
eb63b9b8 | 47 | .RE |
eb63b9b8 KZ |
48 | will turn them into |
49 | .IR foo001 ", ..., " foo009 ", " foo010 ", ..., " foo278 . | |
eb63b9b8 KZ |
50 | And |
51 | .RS | |
03b3d715 | 52 | .PP |
eb63b9b8 KZ |
53 | .nf |
54 | rename .htm .html *.htm | |
55 | .fi | |
03b3d715 | 56 | .PP |
eb63b9b8 | 57 | .RE |
eb63b9b8 | 58 | will fix the extension of your html files. |
7d85a7e9 K |
59 | Provide an empty string for shortening: |
60 | .RS | |
61 | .PP | |
62 | .nf | |
63 | rename '_with_long_name' '' file_with_long_name.* | |
64 | .fi | |
65 | .PP | |
66 | .RE | |
67 | will remove the substring in the filenames. | |
03b3d715 | 68 | .SH WARNING |
990bf1f0 AR |
69 | The renaming has no safeguards except the |
70 | .B \-\-no\-act | |
71 | option. If the user has | |
72 | permission to rewrite file names, the command will perform the action without | |
73 | any questions. For example, the result can be quite drastic when the command | |
74 | is run as root in the /lib directory. Always make a backup before running the | |
75 | command, unless you truly know what you are doing. | |
d6cf9e16 SK |
76 | .SH "EXIT STATUS" |
77 | .RS | |
78 | .PD 0 | |
79 | .TP | |
80 | .B 0 | |
81 | all requested rename operations were successful | |
82 | .TP | |
83 | .B 1 | |
84 | all rename operations failed | |
85 | .TP | |
86 | .B 2 | |
87 | some rename operations failed | |
88 | .TP | |
89 | .B 4 | |
90 | nothing was renamed | |
91 | .TP | |
92 | .B 64 | |
93 | unanticipated error occurred | |
94 | .PD | |
95 | .RE | |
eb63b9b8 KZ |
96 | .SH "SEE ALSO" |
97 | .BR mv (1) | |
86d62711 | 98 | .SH AVAILABILITY |
601d12fb | 99 | The rename command is part of the util-linux package and is available from |
d673b74e | 100 | https://www.kernel.org/pub/linux/utils/util-linux/. |