|
Home > Archive > Unix Shell > November 2006 > Rename file names to lower case, but not dirs
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Rename file names to lower case, but not dirs
|
|
| * Tong * 2006-11-28, 1:32 am |
| Hi,
I'm trying to rename names of all files under the current dir to lower
case, but keep dir names as-is.
Is there any way to tweak the following to suit the above goal?
find . -print0 | xargs -t0 rename 'y/A-Z/a-z/'
or else?
thanks
--
Tong (remove underscore(s) to reply)
http://xpt.sourceforge.net/
--
Posted via a free Usenet account from http://www.teranews.com
| |
| Bill Marcum 2006-11-28, 1:32 am |
| On Tue, 28 Nov 2006 00:00:51 -0500, * Tong *
<sun_tong_001@users.sourceforge.net> wrote:
> Hi,
>
> I'm trying to rename names of all files under the current dir to lower
> case, but keep dir names as-is.
>
> Is there any way to tweak the following to suit the above goal?
>
> find . -print0 | xargs -t0 rename 'y/A-Z/a-z/'
>
find . -type f ...
--
Wow, I'm being shot at from both sides. That means I *must* be right. :-)
-- Larry Wall in <199710211959.MAA18990@wall.org>
| |
| Adam Price 2006-11-28, 1:32 am |
| On Tue, 28 Nov 2006 00:00:51 -0500, * Tong * wrote:
> Hi,
>
> I'm trying to rename names of all files under the current dir to lower
> case, but keep dir names as-is.
>
> Is there any way to tweak the following to suit the above goal?
>
> find . -print0 | xargs -t0 rename 'y/A-Z/a-z/'
>
> or else?
>
> thanks
>
> --
> Tong (remove underscore(s) to reply)
> http://xpt.sourceforge.net/
find . -type f ...
| |
| Stephane CHAZELAS 2006-11-28, 1:32 am |
| 2006-11-28, 00:00(-05), * Tong *:
> Hi,
>
> I'm trying to rename names of all files under the current dir to lower
> case, but keep dir names as-is.
>
> Is there any way to tweak the following to suit the above goal?
>
> find . -print0 | xargs -t0 rename 'y/A-Z/a-z/'
>
> or else?
[...]
I'd do
zmv -Qv '(**/)(*)(.D)' '$1${(L)2}'
(using zsh and its autoloadable zmv function).
Or, as you seem to have GNU find and the PERL based rename
command:
find . -type f -name '*[[:upper:]]' -print0 -exec rename -v '
s,(.*/)(.*),$1\L$2,' {} +
If you don't want to recurse into subdirectories, you can use
the non-standard -maxdepth or do:
find . ! -name . -prune -type f -name '*[[:upper:]]*' -exec \
rename '$_=lc' {} +
--
Stéphane
|
|
|
|
|