Copying to destination folders using a wildcard

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

TViens

Posts: 3
Joined: Fri Aug 01, 2014 10:26 am

Post by TViens » Fri Aug 01, 2014 1:15 pm
I am trying to create a standard project for use with monitors. The directory structure is consistent for all projects.
<project dir>/inbound //Source files are place here by external systems
<project dir>/archive
<project dir>/outbound_example1
<project dir>/outbound_example2
<project dir>/outbound_example3

What I am trying to accomplish in the project is to take all files from the inbound directory and copy them to the outbound directories using a wildcard, <project dir>/outbound_* as an example.

If this can be accomplished the inbound script can be used without modification for all inbounds as long as the directory structure is consistent.

Can a wildcard be used in the copy command?
Can this be done without a loop?

Support_Rick

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

Post by Support_Rick » Mon Aug 04, 2014 4:34 pm
Ted,

This can be accomplished by using local file system commands to generate the Folder List into a Temporary File. Then, read that file to get the folder names and copy to them. In pseudo terms,

Execute Local command: ls -d * > workspace/DirList.txt
Read DirList.txt
ForEach Inbound File
ForEach DirList / ThisDir
Copy From Inbound -> ${ThisDir}
/ForEach
/ForEach

Hope this helps!
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696

TViens

Posts: 3
Joined: Fri Aug 01, 2014 10:26 am

Post by TViens » Tue Nov 04, 2014 2:34 pm
A solution was developed for this. What this solution allowed me to do was to create new monitors using a template script so that I can add and remove FTPs with easy using a standard structure in the file system.

My original solution is shown below. Linoma software recently added functionality to allow for this design. This distribution script is also responsible for zipping, archiving, etc.
Code: Select all
<project name="Distribute Inbound Files to Outbound Directories" mainModule="Main" version="2.0" logLevel="verbose" threadSafe="true">
	<variable name="files" value="" description="FileList variable transferred from Monitor" />
	<variable name="projectDirectory" value="" description="Root folder to process" />

	<module name="Main">

		<createWorkspace label="temp_workspace" version="1.0" disabled="false" />


		<exec label="list directories" executable="/data/utilities/getOutboundDirs.sh" outputFileVariable="fileList" version="1.0">
			<arg value="${projectDirectory}" />
			<arg value="${system.job.workspace}" />
		</exec>


		<readFlatFile label="Read File - Directory List" inputFile="${system.job.workspace}/${dirListFile}" outputRowSetVariable="directoryList" recordDelimiter="LF" trim="both" version="1.0" disabled="false" />

		<forEachLoop label="Copy files to the outbound directories" itemsVariable="${directoryList}" currentItemVariable="currentDirectory" disabled="false">

			<copy label="Copy inbound files to outbound directories" sourceFilesVariable="${files}" destDir="${currentDirectory[1]}" whenFileExists="overwrite" version="1.0" />

		</forEachLoop>

		<move label="Move files to archive" sourceFilesVariable="${files}" destDir="${projectDirectory}/archive" suffix="_${CurrentTimestamp(&apos;yyyymmddHHmm&apos;)}" destinationFilesVariable="filesProcessed" version="1.0" />


		<tar label="Compress Archive Files" inputFilesVariable="${filesProcessed}" outputFile="${projectDirectory}/archive/Archive_${CurrentTimestamp(&apos;yyyyMMddhhmm&apos;)}.tar.gz" compress="true" version="1.0" disabled="false" />


		<zip label="Zip Archive Files" inputFilesVariable="${filesProcessed}" outputFile="${projectDirectory}/archive/Archive_${CurrentTimestamp(&apos;yyyyMMddhhmm&apos;)}.zip" version="1.0" disabled="true" />


		<delete inputFilesVariable="${filesProcessed}" version="1.0" />


		<deleteWorkspace label="temp_workspace" version="1.0" disabled="false" />

	</module>

	<description>The purpose of this project is to distribute inbound files to outbound directories based on the parameters passed in the monitor job configuration.</description>
	<variable name="dirListFile" value="dirList.txt" description="This variable holds the value of the file name containing the directory listing." />
</project>
3 posts Page 1 of 1