#!/usr/bin/perl -w use strict; use File::Copy; #rather than renaming my $path = "/home/ftp/pub/mp3s/"; #just in case move needs a full path chdir $path; my @lists = ; foreach (@lists){ open (FH, $_) || die "Could not read file :$!"; my $dir = $_ . "_dir"; mkdir $dir; #dir that we want to move the files into while (){ chomp; my $orig = $_; s!/.*/(.*/.*)!$1!; #keep last dir + file name in new dir my $dest = $path . $dir . "/" . $_; move $orig,$dest || die "Could not move $orig to $dest: $!"; } }