Move files newly created files from an existing folder

Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
2 posts Page 1 of 1

intl_sp

Posts: 11
Joined: Wed Oct 01, 2014 8:49 am

Post by intl_sp » Wed Oct 22, 2014 9:45 am
We have this requirement to move newly created files from an Archive folder that contains files from over a year.

While doing so, is their a way to completely avoid the ForEachLoop ?
We are working under restrictions for e.g we cannot modify the existing folder structure.

I am aware that a monitor can be used to detect new files, but how can the job decide which files are created say 'today' and transfer only those?

Support_Rick

Support Specialist
Posts: 590
Joined: Tue Jul 17, 2012 2:12 pm
Location: Phoenix, AZ

Post by Support_Rick » Fri Oct 24, 2014 11:07 am
The best solution is to determine your CutOff date ...

ie, Cutoff = Today - 30 days.

Then create a file list across your Archive folder structure generating a file list and only include files dated up to and including your Cutoff date.

Something like the following:
Code: Select all
<timestamp version="1.0">
	<format outputVariable="Cutoff" pattern="yyyy-MM-dd" dayOfMonth="-30" />
</timestamp>


<createFileList label="Get files to Delete" fileListVariable="FilesToDelete" numFilesFoundVariable="NoFilesToDelete" version="1.0">
	<fileset dir="\\MyArchive\MyFolder\MySubFolder" recursive="true">
		<dateFilter>
			<include to="${Cutoff}" />
		</dateFilter>
	</fileset>
</createFileList>
Now you have the Number of files that were found (NoFilesToDelete) that matches your Cutoff criteria, and you have a FileList (FilesToDelete) that you can do whatever you need with that identified list.

No ForEach loop is needed to delete those files unless you want to do each individually.

This can be called from a Scheduled Job to run once a week or once a month ... a Monitor isn't needed.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
2 posts Page 1 of 1