in reply to Re: how to copy source folder excluding specific set of sub folder from parent folder
in thread how to copy source folder excluding specific set of sub folder from parent folder
hi robby_dobby.... in continuation to the above querry i have written a code to copy a directory and delete .svn file in particular from the copy directory. havnt used file::Rsync option but written a subroutine to do so but its doing nothing and stucked in infinite loop. the directory is copied but after that when i called subrouting it was stuck in infinite loop showing - only ...the code is
please suggestuse strict; use warnings; use File::Copy; use File::Basename; use Cwd; use File::Copy::Recursive qw(dircopy) ; ############################################################ sub traversedir { my $givendir = $_[0]; opendir(my $findsvn , $givendir) or die "Couldn't read dir: $! \n +"; my @traversedfiles = readdir($findsvn); foreach my $searchfile (@traversedfiles) { $searchfile =~ /^\.svn$/; print "$searchfile\n"; rmdir $searchfile; if ( -d $searchfile) { &traversedir($searchfile); } else { last; } } } ############################################################ my $fullpath = cwd(); my $value = 0; my $file = basename($fullpath); my $dir = dirname($fullpath); print("\nWORK DIRECTORY PATH IS $dir \n"); opendir(my $pathindex, $dir ) or die "Couldn't read index : $!\n"; while (my $currentfile = readdir($pathindex)) { print "\nCurrent Directory File $value\t"; print "$currentfile","\n"; $value++; } print "\nENTER THE PROJECT NAME FROM ABOVE LIST\n\n"; my $projectdir = <STDIN>; chop($projectdir); my $projectdirpath = "/"."$projectdir"; my $workingdirectory = ($dir.$projectdirpath); chdir($workingdirectory."/trunk"); my $newpath = cwd(); my $topprojectdir = $newpath; my $source_dirrtl; my $target_dirrtl ; opendir(my $index, $newpath ) or die "Couldn't read index : $!\n"; while (my $file = readdir($index)) { if ($file eq "rtl" ) { if(chdir($newpath."/rtl")) { my $currentworkingdir = cwd(); $source_dirrtl = $currentworkingdir; $target_dirrtl = ("$newpath"."/rtl2"); } last; } elsif ($file eq "vhdl") { if(chdir($newpath."/vhdl")) { my $currentworkingdir = cwd(); $source_dirrtl = $currentworkingdir; $target_dirrtl = ("$newpath"."/vhdl2"); } last; } } closedir($index); my $source_dirsim = ("$newpath"."/sim"); my $target_dirsim1 = ("$newpath"."/sim2"); my $source_dirsynth; my $target_dirsynth1 ; opendir(my $indexs, $newpath ) or die "Couldn't read indexs : $!\n"; while (my $file = readdir($indexs)) { if ($file eq "par" ) { if(chdir($newpath."/par")) { my $currentworkingdir = cwd(); $source_dirsynth = $currentworkingdir; $target_dirsynth1 = ("$newpath"."/par2"); } last; } elsif ($file eq "synth") { if(chdir($newpath."/synth")) { my $currentworkingdir = cwd(); $source_dirsynth = $currentworkingdir; $target_dirsynth1 = ("$newpath"."/synth2"); } last; } } closedir($indexs); mkdir($target_dirrtl,0777); mkdir($target_dirsim1,0777); mkdir($target_dirsynth1,0777); my $filertl = dircopy($source_dirrtl, $target_dirrtl); my $filesim = dircopy($source_dirsim, $target_dirsim1); my $filesynth = dircopy($source_dirsynth, $target_dirsynth1); &traversedir($target_dirrtl);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: how to copy source folder excluding specific set of sub folder from parent folder
by soonix (Chancellor) on Aug 11, 2016 at 09:43 UTC | |
|
Re^3: how to copy source folder excluding specific set of sub folder from parent folder
by robby_dobby (Hermit) on Aug 11, 2016 at 10:14 UTC | |
by soonix (Chancellor) on Aug 14, 2016 at 09:58 UTC | |
by robby_dobby (Hermit) on Aug 14, 2016 at 14:08 UTC | |
by soonix (Chancellor) on Aug 14, 2016 at 17:56 UTC | |
by robby_dobby (Hermit) on Aug 16, 2016 at 09:26 UTC |