in reply to Re^2: mv files from dir1 to dir2
in thread mv files from dir1 to dir2
in /testdir1/Results_2008:
12774L1_LacZ.SEE.rc_C06_2008-12-01.ab1 12774L1_SD_B06_2008-12-01.ab1 12774L1_pgK.Neo.2fw_D06_2008-12-01.ab1 12774L1_SU_A06_2008-12-01.ab1
in /testdir1/Results_2009: no files
My script:
OUTPUT:#!/usr/bin/perl use warnings; use strict; my $topdir = "/home/zentara/testdir1"; my @subdirs = get_sub_dirs($topdir); my $newdir = "/home/zentara/testdir2"; sub get_sub_dirs { my $dir = shift; opendir my $dh, $dir or die "Error: $!"; # print "$dh\n"; #this is your glob my @dirs = readdir $dh; @dirs = grep /^Results(.*)$/,@dirs; closedir $dh; return @dirs; } print "subdirs = @subdirs\n"; foreach my $dir(@subdirs){ opendir my $dh, "$topdir/$dir" or die "Error: $!"; my @files = readdir $dh; print "raw files = @files\n"; @files = grep /^(\d+\D\d)_(LacZ|pgK|SD|SU)(.*)$/,@files; print "$dir -> @files\n"; foreach my $file(@files){ # system( "mv $topdir/$dir/$file $newdir/$file"); } closedir $dh; }
subdirs = Results_2008 Results_2009
raw files = . .. 12774L1_SU_A06_2008-12-01.ab1 12774L1_pgK.Neo.2fw_D06_2008-12-01.ab1 12774L1_LacZ.SEE.rc_C06_2008-12-01.ab1 12774L1_SD_B06_2008-12-01.ab1
Results_2008 -> 12774L1_SU_A06_2008-12-01.ab1 12774L1_pgK.Neo.2fw_D06_2008-12-01.ab1 12774L1_LacZ.SEE.rc_C06_2008-12-01.ab1 12774L1_SD_B06_2008-12-01.ab1
raw files = . .. Results_2009 ->
You must have some overlooked spelling error in your pathnames or something?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: mv files from dir1 to dir2
by lomSpace (Scribe) on Jan 12, 2009 at 19:11 UTC | |
by zentara (Cardinal) on Jan 12, 2009 at 19:16 UTC | |
by lomSpace (Scribe) on Jan 13, 2009 at 03:52 UTC | |
|
Re^4: mv files from dir1 to dir2
by lomSpace (Scribe) on Jan 12, 2009 at 19:23 UTC |