[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
On Wed, Dec 24, 2008 at 09:49:45AM +0000, Simon Robert wrote:
> I need to rename, for example, cindi_001-l.jpg to cindi_001.jpg.
>
> The cms app that this site runs has a rename app using regular
> expressions. I've tried, but can't get it to work, would anyone know the
> regexp for the above change?
>
You want to rename all files removing the "-l"?
ie
cindi_001-l.jpg to cindi_001.jpg
cindi_002-l.jpg to cindi_002.jpg
?
If you are talking about the "rename" command (came with Debian Perl) then what has
worked for me is
~$ rename 's/old_file_regex/new_file_regex/' matching_file
So in the above example I would try
~$ rename 's/-l\.jpg/\.jpg/' *.jpg
See bottom of http://www.debian-administration.org/articles/150
Quote
A simple one is the rename command which is included with the Debian perl
package and almost certainly available to you already.
The rename command allows you to rename files with full perl expressions,
in a simple manner.
For example our preceding example of changing the extension can be
achieved with:
skx@lappy:~$ rename 's/\.JPG/\.jpg/' *.JPG
We can also, for example, strip spaces from filenames with this:
skx@lappy:~$ rename 's/ //' *.JPG
Renaming files from upper to lower case can be a simple job:
skx@lappy:~$ rename 'y/A-Z/a-z/' *
Unquote
--
Henry
Photocopies or faxes of my signature are not binding.
This email has been signed with an electronic signature in accordance with
subsection 7(3) of the Electronic Communications Act 2000.
Digital Key Signature: GPG RSA 0xFB447AA1
Wed Dec 24 10:19:42 GMT 2008
Attachment:
signature.asc
Description: Digital signature
-- The Mailing List for the Devon & Cornwall LUG http://mailman.dclug.org.uk/listinfo/list FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html