Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
perl script to expand folders?
System
Looking for a script that loops through all folders assigned to a workflow, adds all foldered files to the workflow, and then cleans itself up by removing the original folders from the workflow. Is it out there?
Find more posts tagged with
Comments
Migrateduser
I have a subroutine that, given an areavpath, which in this case is assumed to be a workarea (it can be easily modified to not assume this), returns a list of all files recursively through all directories and subdirectories underneath the passed in path. No directory names are returned in the list - only specific filenames. This is written for Solaris. You could modify this subroutine easily to add these files to your workflow and then remove the original list of directories.
For what it's worth, here's the subroutine:
sub get_recursive_files {
my ($basepath) =
@_
;
my
@files
= ();
my
@basefiles
= ();
my $prefix = $basepath;
if ($prefix =~ /^.*WORKAREA\/[^\/]*\/(.*)$/) {
$prefix = $1;
}
else {
$prefix = '';
}
return
@files
if (!-d $basepath);
opendir BASE,$basepath;
@basefiles
= readdir BASE;
closedir BASE;
# Recursively retrieve all files
foreach my $file (
@basefiles)
{
if ((-d "$basepath/$file") && ($file !~ /^\.+$/)) {
push
@files
, get_recursive_files("$basepath/$file");
}
else {
push (
@files
, "$prefix$file") if ($file !~ /^\.+$/);
}
}
return
@files
;
}
Dave Smith
DavidH.Smith@nike.com