Re: [SLUG] File Renaming

From: Eben King (eben1@tampabay.rr.com)
Date: Fri Aug 20 2004 - 16:51:05 EDT


On Fri, 20 Aug 2004, Levi Bard wrote:

> My contribution:
> ---
> #!/bin/sh
> # renamemany.sh
> # renames all files in given directories from /path/to/file ->
> /path/to/path-to-file
> # Usage: renamemany.sh dir1 dir2 dir3 ...
>
> for dir in "$@"
> do
> for i in `find "${dir}" -name '*' | grep '/[^$]'`
                                  ^^^^^^^^^
Skip that... it's the same as

          for i in `find "${dir}" | grep '/[^$]'`
                                    ^^^^^^^^^^^^

What does this do?

While I'm at it, you can do

          for i in `ls "${dir}" | grep '/[^$]'`
> do
> ipath=`echo "$i" | sed 's,/[^/]*$,/,'`
> newname=`echo "$i" | sed 's,/,-,g'`
> mv -i "$i" "${ipath}${newname}"
> done
> done

-- 
-eben    ebQenW1@EtaRmpTabYayU.rIr.OcoPm    home.tampabay.rr.com/hactar

Logic is a systematic method of coming to the wrong conclusion with confidence.

----------------------------------------------------------------------- This list is provided as an unmoderated internet service by Networked Knowledge Systems (NKS). Views and opinions expressed in messages posted are those of the author and do not necessarily reflect the official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 15:04:13 EDT