LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 996|回复: 7

如何把一个目录下的文件名全转化成为大写?

[复制链接]
发表于 2004-5-28 11:33:38 | 显示全部楼层 |阅读模式
如何把一个目录下的文件名全转化成为大写?
方法越简单越好
发表于 2004-5-28 11:55:40 | 显示全部楼层
这样的讨论本版很多,方法也很多,望兄弟善用搜索!
  1. for i in *;do [[ -f $i ]]&&mv $i $(echo $i|tr a-z A-Z);done
复制代码
 楼主| 发表于 2004-5-28 19:10:53 | 显示全部楼层

Thanks

Thanks
我想了一个很笨的办法,就是:
ls * > out1
cat out1 | tr [a-z] [A-Z] > out 2
然后用rename命令
哈哈哈,晕倒吧……
发表于 2004-5-30 09:25:52 | 显示全部楼层
rename 'y/a-z/A-Z/' *
 楼主| 发表于 2004-5-30 16:37:09 | 显示全部楼层
能详细说说 rename 'y/a-z/A-Z/' * 是什么意思吗?
发表于 2004-5-31 12:01:44 | 显示全部楼层
man rename:

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 exten-
       sion, you might say
                                                                                                      
               rename 's/\.bak$//' *.bak
                                                                                                      
       To translate uppercase names to lower, you'd use
                                                                                                      
               rename 'y/A-Z/a-z/' *

我不懂perlexpr,请查他的规则
发表于 2004-5-31 12:09:55 | 显示全部楼层
呵呵,看我的man rename
RENAME(1)                  Linux Programmer's Manual                 RENAME(1)

NAME
       rename - Rename files

SYNOPSIS
       rename from to file...

DESCRIPTION
       rename  will  rename  the specified files by replacing the first occur-
       rence of from in their name by to.

       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
       mv(1)

                                1 January 2000                       RENAME(1)
(END)
 楼主| 发表于 2004-5-31 12:12:53 | 显示全部楼层
Thank a lot
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表