Results 1 to 3 of 3

Thread: Renaming multiple files

  1. #1
    Join Date
    May 2015
    Location
    Tempe, AZ
    Beans
    20
    Distro
    Ubuntu 14.04 Trusty Tahr

    Renaming multiple files

    I'm trying to use the utility rename to look for a year, right now 20??. And add parentheses around it without dropping off the 06, 16, or 18. Eventually I will be renaming things that are 19??. The issue I'm running into is that the replace section will either add the parentheses are the brackets with the character group in it instead of just adding the parentheses and keeping the numbers.

    Does anyone have suggested because that's just the start but I think I can remove everything from between the year or resolution and the file extension.

  2. #2
    Join Date
    Dec 2014
    Beans
    1,123

    Re: Renaming multiple files

    Code:
    rename -n 's/\b(20[01][0-9]|19[0-9]{2})\b/($1)/' *
    should cover both the 20xx and the 19xx case. The option '-n' makes rename print out what it would do without actually renaming anything. Use it as written (with the option) until you're certain it will do what you want.
    'rename' is written in Perl and uses Perl regular expressions. You can find details (lots and lots of 'em) in the man pages 'perlretut', 'perlrequick', 'perlfaq6', 'perlre', 'perlrebackslash', 'perlrecharclass', and 'perlreref' from the package 'perl-doc'.

    Holger

  3. #3
    Join Date
    Jun 2006
    Location
    UK
    Beans
    Hidden!
    Distro
    Ubuntu 18.04 Bionic Beaver

    Re: Renaming multiple files

    Thread moved to General Help.

    The Multimedia Software sub-forum is for help with - well - multimedia software.
    Ubuntu 16.04 Desktop Guide - Ubuntu 18.04 Desktop Guide - Forum Guide to BBCode - Using BBCode code tags - IRC #ubuntuforums

    Member: Not Canonical Team

    Please do not PM me about your forum account unless you have been asked to. The correct place to contact an admin about your account is here.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •