help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] how to bulk rename files


From: Clark J. Wang
Subject: Re: [Help-bash] how to bulk rename files
Date: Fri, 13 Apr 2012 10:00:07 +0800

On Thu, Apr 12, 2012 at 11:20, DJ Mills <address@hidden> wrote:
not when you iterate over the glob with for.

I did not know this before. Thanks.
 
if that were the case, your command will have the same issue. and of course find -exec eill not have a problem

------Original Message------
From: Clark Wang <address@hidden>
To: "DJ Mills" <address@hidden>
Cc: "Eric Blake" <address@hidden>,<address@hidden>
Date: Thursday, April 12, 2012 11:05:41 AM GMT+0800
Subject: Re: [Help-bash] how to bulk rename files

On Thu, Apr 12, 2012 at 04:54, DJ Mills <address@hidden> wrote:

> On Wed, Apr 11, 2012 at 4:51 PM, Eric Blake <address@hidden> wrote:
> > On 04/11/2012 02:44 PM, address@hidden wrote:
> >> I have many files, 2.5 million, that I have to make available to Windows
> >> folks
> >> They demand that the files have a extension added
> >> Is there an efficient method of bulk renaming files
> >
> > If you're wanting to use just bash features:
> >
> > for f in $(generate your list of files); do
> >  mv "$f" "$f.ext"
> > done
> >
> > If you want efficient, there's several purpose-built tools for this job,
> > but it is no longer a question for the bash list.  My favorite:
> >
> > man mmv
> >
> > --
> > Eric Blake   address@hidden    +1-919-301-3266
> > Libvirt virtualization library http://libvirt.org
> >
>
> This is a TERRIBLE idea, as attempting to word-split a command
> substitution will fail horribly on any filenames with spaces (which is
> very common in Windows), and will attempt pathname expansion on the
> output. A simple glob should be used, or -exec if find is used.
>

A glob expansion may cause the command line to be too long since the OP has
2.5 million files?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]