diff --git a/pages/common/file-rename.md b/pages/common/file-rename.md new file mode 100644 index 0000000000..417d5882c1 --- /dev/null +++ b/pages/common/file-rename.md @@ -0,0 +1,7 @@ +# file-rename + +> This command is an alias of `rename`. + +- View documentation for the original command: + +`tldr -p common rename` diff --git a/pages/common/perl-rename.md b/pages/common/perl-rename.md new file mode 100644 index 0000000000..ca469cec82 --- /dev/null +++ b/pages/common/perl-rename.md @@ -0,0 +1,7 @@ +# perl-rename + +> This command is an alias of `rename`. + +- View documentation for the original command: + +`tldr -p common rename` diff --git a/pages/common/prename.md b/pages/common/prename.md new file mode 100644 index 0000000000..698097eea8 --- /dev/null +++ b/pages/common/prename.md @@ -0,0 +1,7 @@ +# prename + +> This command is an alias of `rename`. + +- View documentation for the original command: + +`tldr -p common rename` diff --git a/pages/common/rename.md b/pages/common/rename.md new file mode 100644 index 0000000000..71c05dbe33 --- /dev/null +++ b/pages/common/rename.md @@ -0,0 +1,30 @@ +# rename + +> Rename a file or group of files with a regular expression. +> WARNING: This command will overwrite files without prompting unless the dry-run option is used. +> Note: This page refers to the Perl version, also known as `file-rename`. +> More information: . + +- Replace `from` with `to` in the filenames of the specified files: + +`rename 's/{{from}}/{{to}}/' {{*.txt}}` + +- Dry-run - display which changes would occur without performing them: + +`rename -n 's/{{from}}/{{to}}/' {{*.txt}}` + +- Change the extension: + +`rename 's/\.old$/\.new/' {{*.txt}}` + +- Change to lowercase (use `-f` in case-insensitive filesystems): + +`rename {{[-f|--force]}} 'y/A-Z/a-z/' {{*.txt}}` + +- Capitalize first letter of every word in the name: + +`rename {{[-f|--force]}} 's/\b(\w)/\U$1/g' {{*.txt}}` + +- Replace spaces with underscores: + +`rename 's/\s+/_/g' {{*.txt}}` diff --git a/pages/linux/file-rename.md b/pages/linux/file-rename.md deleted file mode 100644 index 1469dbad3b..0000000000 --- a/pages/linux/file-rename.md +++ /dev/null @@ -1,25 +0,0 @@ -# rename - -> Rename multiple files. -> Note: This page refers to the command from the `rename` Debian package. -> More information: . - -- Rename files using a Perl Common `regex` (substitute 'foo' with 'bar' wherever found): - -`rename {{'s/foo/bar/'}} {{*}}` - -- Dry-run - display which renames would occur without performing them: - -`rename {{[-n|--nono]}} {{'s/foo/bar/'}} {{*}}` - -- Force renaming even if the operation would remove existing destination files: - -`rename {{[-f|--force]}} {{'s/foo/bar/'}} {{*}}` - -- Convert filenames to lower case (use `-f` in case-insensitive filesystems to prevent "already exists" errors): - -`rename 'y/A-Z/a-z/' {{*}}` - -- Replace whitespace with underscores: - -`rename 's/\s+/_/g' {{*}}` diff --git a/pages/linux/perl-rename.md b/pages/linux/perl-rename.md deleted file mode 100644 index fce0047068..0000000000 --- a/pages/linux/perl-rename.md +++ /dev/null @@ -1,25 +0,0 @@ -# rename - -> Rename multiple files. -> Note: This page refers to the command from the `perl-rename` Arch Linux package. -> More information: . - -- Rename files using a Perl Common `regex` (substitute 'foo' with 'bar' wherever found): - -`rename {{'s/foo/bar/'}} {{*}}` - -- Dry-run - display which renames would occur without performing them: - -`rename {{[-n|--no-act]}} {{'s/foo/bar/'}} {{*}}` - -- Force renaming even if the operation would remove existing destination files: - -`rename -f {{'s/foo/bar/'}} {{*}}` - -- Convert filenames to lower case (use `-f` in case-insensitive filesystems to prevent "already exists" errors): - -`rename 'y/A-Z/a-z/' {{*}}` - -- Replace whitespace with underscores: - -`rename 's/\s+/_/g' {{*}}` diff --git a/pages/linux/prename.md b/pages/linux/prename.md deleted file mode 100644 index 3906b62b17..0000000000 --- a/pages/linux/prename.md +++ /dev/null @@ -1,25 +0,0 @@ -# rename - -> Rename multiple files. -> Note: This page refers to the command from the `prename` Fedora package. -> More information: . - -- Rename files using a Perl Common `regex` (substitute 'foo' with 'bar' wherever found): - -`rename {{'s/foo/bar/'}} {{*}}` - -- Dry-run - display which renames would occur without performing them: - -`rename {{[-n|--nono]}} {{'s/foo/bar/'}} {{*}}` - -- Force renaming even if the operation would remove existing destination files: - -`rename {{[-f|--force]}} {{'s/foo/bar/'}} {{*}}` - -- Convert filenames to lower case (use `-f` in case-insensitive filesystems to prevent "already exists" errors): - -`rename 'y/A-Z/a-z/' {{*}}` - -- Replace whitespace with underscores: - -`rename 's/\s+/_/g' {{*}}` diff --git a/pages/linux/rename.md b/pages/linux/rename.md index 92940e4f96..0d9f1a9c71 100644 --- a/pages/linux/rename.md +++ b/pages/linux/rename.md @@ -1,31 +1,11 @@ # rename -> Rename multiple files. -> Note: This page refers to the command from the `util-linux` package. -> For the Perl version, see `file-rename` or `perl-rename`. -> Warning: This command has no safeguards and will overwrite files without prompting. -> More information: . +> `rename` can refer to multiple commands with the same name. -- Rename files using simple substitutions (substitute 'foo' with 'bar' wherever found): +- View documentation for the Perl version: -`rename {{foo}} {{bar}} {{*}}` +`tldr -p common rename` -- Dry-run - display which renames would occur without performing them: +- View documentation for the `util-linux` version: -`rename {{[-vn|--verbose --no-act]}} {{foo}} {{bar}} {{*}}` - -- Do not overwrite existing files: - -`rename {{[-o|--no-overwrite]}} {{foo}} {{bar}} {{*}}` - -- Change file extensions: - -`rename {{.ext}} {{.bak}} {{*.ext}}` - -- Prepend "foo" to all filenames in the current directory: - -`rename {{''}} {{'foo'}} {{*}}` - -- Rename a group of increasingly numbered files zero-padding the numbers up to 3 digits: - -`rename {{foo}} {{foo00}} {{foo?}} && rename {{foo}} {{foo0}} {{foo??}}` +`tldr rename.util` diff --git a/pages/linux/rename.util.md b/pages/linux/rename.util.md new file mode 100644 index 0000000000..72a06b55c8 --- /dev/null +++ b/pages/linux/rename.util.md @@ -0,0 +1,30 @@ +# rename + +> Rename multiple files. +> WARNING: This command will overwrite files without prompting unless the dry-run option is used. +> Note: This page refers to the command from the `util-linux` package. +> More information: . + +- Rename files using simple substitutions (substitute 'foo' with 'bar' wherever found): + +`rename {{foo}} {{bar}} {{*}}` + +- Dry-run - display which renames would occur without performing them: + +`rename {{[-vn|--verbose --no-act]}} {{foo}} {{bar}} {{*}}` + +- Do not overwrite existing files: + +`rename {{[-o|--no-overwrite]}} {{foo}} {{bar}} {{*}}` + +- Change file extensions: + +`rename {{.ext}} {{.bak}} {{*.ext}}` + +- Prepend "foo" to all filenames in the current directory: + +`rename {{''}} {{'foo'}} {{*}}` + +- Rename a group of increasingly numbered files zero-padding the numbers up to 3 digits: + +`rename {{foo}} {{foo00}} {{foo?}} && rename {{foo}} {{foo0}} {{foo??}}` diff --git a/pages/osx/rename.md b/pages/osx/rename.md deleted file mode 100644 index dda4d3d678..0000000000 --- a/pages/osx/rename.md +++ /dev/null @@ -1,8 +0,0 @@ -# rename - -> Rename a file or group of files with a `regex`. -> More information: . - -- Replace `from` with `to` in the filenames of the specified files: - -`rename 's/{{from}}/{{to}}/' {{*.txt}}`