prename directoy fix

Bug #408392 reported by Mario Schwalbe on 2009-08-03
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
perl (Ubuntu)
Undecided
Unassigned

Bug Description

Binary package hint: perl

Hi,

I like to use find and perl's rename utility to massively rename files. However prename also applies the supplied regular expression to the whole path not just the filename part, although it obviously cannot rename the directory part. Here's an example:

% /usr/bin/rename -n 's/A/a/' dirA/fileA
dirA/fileA renamed as dira/fileA
% /usr/bin/rename -n 's/A/a/g' dirA/fileA
dirA/fileA renamed as dira/filea

Both examples would fail without -n. Instead, it should better work like this, only applying the regex to the filename part:

% local/scripts/rename -n 's/A/a/' dirA/fileA
dirA/fileA renamed as dirA/filea
% local/scripts/rename -n 's/A/a/g' dirA/fileA
dirA/fileA renamed as dirA/filea

Although, I know it is possible to write regular expressions that work this way, it is difficult to get it right and more difficult to use this tool. A patch has been attached.

for reference:
# lsb_release -rd
Description: Ubuntu 9.04
Release: 9.04

# apt-cache policy perl
perl:
  Installed: 5.10.0-19ubuntu1.1
  Candidate: 5.10.0-19ubuntu1.1
  Version table:
     5.10.0-24ubuntu2 0
          1 http://de.archive.ubuntu.com karmic/main Packages
 *** 5.10.0-19ubuntu1.1 0
        500 http://security.ubuntu.com jaunty-security/main Packages
        500 http://de.archive.ubuntu.com jaunty-updates/main Packages
        100 /var/lib/dpkg/status
     5.10.0-19ubuntu1 0
        500 http://de.archive.ubuntu.com jaunty/main Packages

Mario Schwalbe (schwalbe) wrote :
Adam Guthrie (therigu) wrote :

I think the current behaviour is what's must intuitive even if the move might fail. Further applying the patch would break backwards capability.

Perhaps you could add another command line switch to enable this functionality? Then could you open a bug against Debian (here: http://bugs.debian.org/cgi-bin/pkgreport.cgi?package=perl) with the amended patch to see whether the Maintainer there will accept it.

tags: added: patch-needswork
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers