Copying a Directory

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

Artis_Wright

Posts: 8
Joined: Tue Dec 06, 2016 2:33 pm

Post by Artis_Wright » Tue Dec 06, 2016 5:10 pm
I am sorry if there is a post regarding this already, however, I was unable to find it.

Basically what I want to do is copy a directory and place that copy someplace else. Here is my code. I am using a workspace because I plan to zip the file before copying the file from the workspace to its new home.
Code: Select all
 <project name="Copy Folder" mainModule="Main" version="2.0" logLevel="verbose">

	<module name="Main">

		<createWorkspace version="1.0" />


		<copy destDir="${system.job.workspace}" version="1.0">
			<fileset dir="C:\X\*">
				<wildcardFilter>
					<include pattern="*" />
				</wildcardFilter>
			</fileset>
		</copy>


		<copy destDir="C:\Y" version="1.0">
			<fileset dir="${system.job.workspace}" />
		</copy>


		<deleteWorkspace version="1.0" />


		<exitProject version="1.0" />

	</module>

</project>

Support_Rick

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

Post by Support_Rick » Tue Dec 06, 2016 5:27 pm
Artis,

You're close! :)

When selecting your fileList, just put the wildcard in the filter, like this:

<fileset dir="C:\X"\>

If you are getting ALL files from the folder, you do not have to specify the wildcard. Only use that when you're wanting something like *.csv or ABC*.txt.

So, I would use something like this instead:

<copy destDir="${system.job.workspace}" destinationFilesVariable="myFiles" version="1.0">
<fileset dir="C:\X"/>
</copy>

Then, use the variable ${myFiles} as input into your zip:

<zip inputFilesVariable="${myFiles}" outputFile="MyZippedFiles.zip" outputFileVariable="zipFile" version="1.0" />

Then, copy your zip file to another location:

Copy ${zipFile} to C:\DestLocation

Try it!
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696

Artis_Wright

Posts: 8
Joined: Tue Dec 06, 2016 2:33 pm

Post by Artis_Wright » Thu Dec 08, 2016 11:41 am
Support_Rick wrote:
Artis,

You're close! :)

When selecting your fileList, just put the wildcard in the filter, like this:

<fileset dir="C:\X"\>

If you are getting ALL files from the folder, you do not have to specify the wildcard. Only use that when you're wanting something like *.csv or ABC*.txt.

So, I would use something like this instead:

<copy destDir="${system.job.workspace}" destinationFilesVariable="myFiles" version="1.0">
<fileset dir="C:\X"/>
</copy>

Then, use the variable ${myFiles} as input into your zip:

<zip inputFilesVariable="${myFiles}" outputFile="MyZippedFiles.zip" outputFileVariable="zipFile" version="1.0" />

Then, copy your zip file to another location:

Copy ${zipFile} to C:\DestLocation

Try it!
Guten Tag,

This worked perfectly but I have one more question. Is there a way I can have it copy the sub directories within the folder that I am copying as well as all of its contents as well? It copied the files just fine but it ignored the folders.

Thanks!

-Artis

Support_Rick

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

Post by Support_Rick » Thu Dec 08, 2016 1:01 pm
Where you set the fileset Dir (C:\X\) .. there's an option for Recursive... just set that value to true.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696

Artis_Wright

Posts: 8
Joined: Tue Dec 06, 2016 2:33 pm

Post by Artis_Wright » Fri Dec 09, 2016 4:09 pm
Thank you, this worked perfectly. It did not work at 1st in testing but I learned that there has to be a file in the folder for it to work.
5 posts Page 1 of 1