Here is what I arrived at with your help of the definitions in your last response.
The reason I"m using a for loop is so I can check what path is being passed in as certain files/directories have different retention requirements.
So, at the end of my script(s), I'd put this:
For this purpose ( & script) I only need to pass in the log and error directories since nothing major happens. However, for data integration scripts, data exports, the _DLIST variable would be inclusive of many more.
Then my function looks like such:
As an example, for this purpose, the following to paths are passed in:
If the baseline folder is detected as YEAR_MONTHDAY format, I strip that off first before purging or else it wouldn't hit the other YEAR_MONTHDAY folders in the /PBCS_Reset_Service_*/ directory.
Let me know if I'm way off base here - thanks!
Last edited by SIMMS7400; 06-15-2018 at 07:49 PM..
Hi,
I want to write a script that deletes all folders and keep the last 10 recent folders.
I know the following:
ls -ltr will sort the folders from old to recent.
ls -ltr | awk '{print $9}' will list the folder names (with a blank line at the beginning)
I want to get the 10th folder from... (3 Replies)
Hi ,
I need a script which basically deltes all files in folder a which are alreasy present in folder b
say folder a has files abc.txt
pqr .txt
and b has abc.txt
pqr.txt
rmr.txt
then file abc.txt and pqr.txt from a should be deleted (6 Replies)
Hi I have files that end with .txt.txt that i want to delete. But I also have files that end with .txt that I want to leave intact. How do I specifically delete files that end with .txt.txt in a folder.
thanks (5 Replies)
Hi all,
I need to write a script to naviagate into the list of specified folder and delete the files in it.
I have mentioned the list of folders in a external file so it can be reusable.
The issue is am facing now is that, i am not understating on how to navigate into the folder locations... (6 Replies)
Hi,
I need to use rsync to delete multiple files(only specified files not all) using --delete option, these files are located in different target folders.
Instead of running rsync command multiple times for each file, can we achieve this with one time execution?
your help is much... (0 Replies)
Hi All,
Need a for loop which should run for number of files in a folder and should pass the file name as parameter to another shell script for each loop.
Please help me.
Thanks. (2 Replies)
Hi Experts,
i need a little help.
i have different folder that contain files that need to be deleted. but those folder contains huge amoung of same with 3 different extention.
what i used to do is to delete them using the rm commande
rm *.ext *.ext1 *.ext3
what i want to do is to have... (1 Reply)
hi i need a script to delete the files older than 2 days...
if my input is say in a folder versions
A_14122012.txt
A_15122012.txt
A_16122012.txt
A_17122012.txt
i want my output to be
A_16122012.txt
A_17122012.txt
thanks in advance
hemanth saikumar. (2 Replies)
Hi Team,
I am new to shell script and there is a requirement where files should be moved from Subfolder to parent folder.
Eg:
parent folder --> /Interface/data/test/IN
Sub folder -->/Interface/data/test/IN/Invoice20180607233338
Subfolder will be always with timestamp... (6 Replies)
Discussion started by: srivarun15
6 Replies
LEARN ABOUT DEBIAN
tree::simple::visitor::createdirectorytree
Tree::Simple::Visitor::CreateDirectoryTree(3pm) User Contributed Perl Documentation Tree::Simple::Visitor::CreateDirectoryTree(3pm)NAME
Tree::Simple::Visitor::CreateDirectoryTree - A Visitor for create a set of directories and files from a Tree::Simple object
SYNOPSIS
use Tree::Simple::Visitor::CreateDirectoryTree;
# create a Tree::Simple object which
# represents a directory heirarchy
my $tree = Tree::Simple->new("www/")
->addChildren(
Tree::Simple->new("conf/")
->addChildren(
Tree::Simple->new("startup.pl"),
Tree::Simple->new("httpd.conf")
),
Tree::Simple->new("cgi-bin/"),
Tree::Simple->new("ht_docs/"),
Tree::Simple->new("logs/")
->addChildren(
Tree::Simple->new("error.log"),
Tree::Simple->new("access.log")
),
);
# create an instance of our visitor
my $visitor = Tree::Simple::Visitor::CreateDirectoryTree->new();
# pass the visitor to a Tree::Simple object
$tree->accept($visitor);
# the www/ directory now mirrors the structure of the tree
DESCRIPTION
This visitor can be used to create a set of directories and files from a Tree::Simple object hierarchy.
METHODS
new There are no arguments to the constructor the object will be in its default state. You can use the "setNodeFilter", "setFileHandler"
and "setDirectoryHandler" methods to customize its behavior.
setNodeFilter ($filter_function)
This method accepts a CODE reference as its $filter_function argument and throws an exception if it is not a code reference. This code
reference is used to filter the tree nodes as they are used to create the directory tree, it can be basically used as a node pre-
processor. An example usage of this might be to enforce the 8.3 naming rules of DOS, or the 32 character limit of older macintoshes.
setFileHandler ($file_handler)
This method accepts a CODE reference as its $file_handler argument and throws an exception if it is not a CODE reference. This method
can be used to create custom file creation behavior. The default behavior is to just create the file and nothing else, but by using
this method it is possible to implement some other custom behavior, such as creating a file based on a template. The function is passed
the full path of the file to be created (as built by File::Spec).
setDirectoryHandler ($dir_handler)
This method accepts a CODE reference as its $dir_handler argument and throws an exception if it is not a CODE reference. This method
can be used to create custom directory creation behavior. The default behavior is to just create the directory and nothing else, but by
using this method it is possible to implement some other custom behavior, such as creating a directory on a remote server. The function
is passed the full path of the directory to be created (as built by File::Spec).
visit ($tree)
This is the method that is used by Tree::Simple's "accept" method. It can also be used on its own, it requires the $tree argument to be
a Tree::Simple object (or derived from a Tree::Simple object), and will throw and exception otherwise.
The tree is processed as follows:
Any node which is not a leaf is considered a directory.
Obviously since files themselves are leaf nodes, this makes sense that non-leaves will be directories.
Any node (including leaf nodes) which ends in either the character "/" or "" is considered a directory.
I think it is a pretty standard convention to have directory names ending in a separator. The separator itself is stripped off
before the directory name is passed to File::Spec where the platform specific directory path is created. This means that it does
not matter which one you use, it will be completely cross platform (at least as cross-platform as File::Spec is).
All other nodes are considered to be files.
BUGS
None that I am aware of. Of course, if you find a bug, let me know, and I will be sure to fix it.
CODE COVERAGE
See the CODE COVERAGE section in Tree::Simple::VisitorFactory for more inforamtion.
SEE ALSO
These Visitor classes are all subclasses of Tree::Simple::Visitor, which can be found in the Tree::Simple module, you should refer to that
module for more information.
AUTHOR
stevan little, <stevan@iinteractive.com>
COPYRIGHT AND LICENSE
Copyright 2004, 2005 by Infinity Interactive, Inc.
<http://www.iinteractive.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.10.1 2010-02-18 Tree::Simple::Visitor::CreateDirectoryTree(3pm)