in reply to renaming files

use strict; use warnings; my ($dir, $file) = './'; ### Directory to process opendir(DIR, $dir) || die; while ($file = readdir(DIR)) { if ($file !~ /_my_guitar\.mp3/ && $file =~ /(.*)\.mp3/) { $_ = "$1_my_guitar.mp3"; `mv $dir$file $dir$_`; ### Or some other rename } }

Replies are listed 'Best First'.
Re^2: renaming files
by discofris (Initiate) on Mar 04, 2012 at 17:45 UTC
    I've been playing with this snippet in order to rename some files inside folders. I have a folder with other folders inside which I would like to rename from somename.nfo to foldername.release.

    Folderstructure is like this:
    complete/La.Haine.1995.1080p.BluRay.DTS.x264-DON/lh-don.mkv
    complete/La.Haine.1995.1080p.BluRay.DTS.x264-DON/lh-don.nfo

    and would like to automagically rename it to this:

    complete/La.Haine.1995.1080p.BluRay.DTS.x264-DON/La.Haine.1995.1080p.BluRay.DTS.x264-DON.mkv
    complete/La.Haine.1995.1080p.BluRay.DTS.x264-DON/La.Haine.1995.1080p.BluRay.DTS.x264-DON.release

    All guidance is welcome :-)