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

Re: [Sheflug] Batch Process Photographs



On 16-Jul-09 13:36:49, Andy (Beta) wrote:
> 2009/7/12 Richard Ibbotson <richard@xxxxxxxxxxxxxx>:
>> I'd like to title 200 photographs so that the image name can be
>> changed from something like dsc3.jpg to holiday3.jpg.  Would be nice
>> if the batch process would convert all images in sequence as well so
>> that dsc1.jpg becomes holiday1.jpg and dsc200.jpg becomes
>> holiday200.jpg
> 
> In Bash:
> 
> rename dsc holiday *.jpg
> 
> Will change the first instance of 'dsc' found in a file name to
> 'holiday' and will do this to all the files ending with '.jpg' in the
> directory.
> 
> Hope that helps.
>     Andy.

'rename' seems to have changed recently. The above recommendation seems
to refer to the older version. See below.

[A] From a 2003 Red Hat distribution:
SYNOPSIS
  rename from to file...
DESCRIPTION
  rename will rename the specified files by replacing the first
  occurrence 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)
-----------------------------------------------------------
[B] From a 2007 Debian distribution:
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
  extension, you might say
    rename ?s/\.bak$//? *.bak
 To translate uppercase names to lower, you'd use
    rename ?y/A-Z/a-z/? *
[...]
BUGS
  The original "rename" did not check for the existence of target
  filenames, so had to be used with care. I hope I've fixed that
  (Robin Barker).
perl v5.8.8                   2008-12-18                 RENAME(1)
-----------------------------------------------------------

So check 'man rename' (and maybe experiement in a test directory
with dummy filenames, to make sure you get what you want!)

Ted.



--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding@xxxxxxxxxxxxxxxx>
Fax-to-email: +44 (0)870 094 0861
Date: 16-Jul-09                                       Time: 15:24:09
------------------------------ XFMail ------------------------------

_______________________________________________
Sheffield Linux User's Group
http://sheflug.org.uk/mailman/listinfo/sheflug_sheflug.org.uk
FAQ at: http://www.sheflug.org.uk/mailfaq.html

GNU - The Choice of a Complete Generation