[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]
On Wed, 2008-12-24 at 10:27 +0000, Henry Bremridge wrote: > 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"? > > i.e. > > 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 > > Thanks. The only way I have of getting at this stuff, apart from the CMS package, is using ftp or maybe telnet. Is the perl package available? Also for various convoluted reasons I do not have direct access to the site. The site is set to only allow access to one specific IP address, that of someone I'm working with. So I log on to his XP machine using a www.logmein.com account (incidentally logmein have a firefox plugin which enables one to use their services to control XP boxes from linux ones (although not the other way around unfortunately)) and run the CMS, ftp from the command line or whatever. So within these limitations (energizing challenges (ha ha)) I need to change the names of a great many files. Any help will be received with vast amounts of help and maybe an Order Of Lenin (with Extra Oak Leaves!). Thanks Simon -- 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