Excel File Size

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

a_houston

User avatar
Verified User
Posts: 4
Joined: Fri Jun 05, 2009 11:38 am
Location: USA

Post by a_houston » Fri Jan 11, 2013 11:09 am
I have a project that creates an Excel file which is then zipped. Is there a way to retrieve the size of the zipped file? The file is created in the project's workspace only.

Support_Rick

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

Post by Support_Rick » Fri Jan 11, 2013 11:34 am
You can retrieve the file size by doing something like the following:
Code: Select all
<project name="FileInfo Test" mainModule="Main" version="2.0" logLevel="silent" threadSafe="true">

	<module name="Main">

		<print label="Display File Size" version="1.0">
			<![CDATA[
===================================================
File Name:  ${ MyFile }
File Size:  ${ FileInfo( MyFile ):size }
===================================================
]]>
		</print>

	</module>

	<variable name="MyFile" value="" />
</project>
The output from this would show:
Code: Select all
01/11/2013 09:28:25           INFO      Overriding variable 'MyFile' with value 'C:\Temp\MyZipFile.zip'
01/11/2013 09:28:25           INFO      
===================================================
File Name:  C:\Temp\MyZipFile.zip
File Size:  21045
===================================================
01/11/2013 09:28:25           INFO      End Date and Time: 01/11/2013 09:28:25
In this example, I'm passing the file location in as a parameter (MyFile). You could easily assign the file name within your project, or define it as a literal location.

For more information, please see the help text (Blue Question Mark within your GoAnywhere Director) and search for FileInfo.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696

a_houston

User avatar
Verified User
Posts: 4
Joined: Fri Jun 05, 2009 11:38 am
Location: USA

Post by a_houston » Fri Jan 11, 2013 12:18 pm
Ric,

Thanks for your response. I must be missing something though because I can't seem to get it to work. Here is a sample of what I am trying to do:

Code: Select all
		<setVariable label="Set File Name" name="MyFile" value="BatchEstimatedCartonizing${userid}${jobnbr}.zip" version="2.0" />

		<setVariable label="Set File Size" name="FileSize" value="${ FileInfo( MyFile ):size}" version="2.0" />
The .zip file was generated in the projects workspace. The variable FileSize always seems to be set to Zero (0).

Support_Rick

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

Post by Support_Rick » Fri Jan 11, 2013 1:00 pm
Try this:
Code: Select all
<project name="FileInfo Test" mainModule="Main" version="2.0">

	<module name="Main">
		<createWorkspace version="1.0" />

		<setVariable label="Init MyZipFile" name="MyZipFile" value="${system.job.workspace}/Pics.zip" version="2.0" />

		<zip label="Zip my Files" outputFile="${ MyZipFile }" whenFileExists="overwrite" version="1.0">
			<fileset dir="C:\Temp">
				<wildcardFilter>
					<include pattern="*.jpg" />
				</wildcardFilter>
			</fileset>
		</zip>

		<print label="Display File Size" version="1.0">
			<![CDATA[===================================================
File Name:  ${ MyZipFile }
File Size:  ${ FileInfo( MyZipFile ):size }
===================================================
]]>
		</print>

		<deleteWorkspace version="1.0" />
	</module>
</project>
Which generates this:
Code: Select all
01/11/2013 10:58:22           INFO      Start Date and Time: 01/11/2013 10:58:22
01/11/2013 10:58:22           INFO      Job Number: 1357908022166 
01/11/2013 10:58:22           INFO      Project Name: /Projects/FileInfo Test
01/11/2013 10:58:22           INFO      Submitted By: RElliott
01/11/2013 10:58:22           INFO      GoAnywhere Director 4.2.0 running on Windows 7 6.1 (amd64)
01/11/2013 10:58:22           INFO      ===================================================
                                        File Name:  C:\Program Files\Linoma Software\GoAnywhere\userdata\workspace\1357908022166/Pics.zip
                                        File Size:  1819758
                                        ===================================================
01/11/2013 10:58:22           INFO      End Date and Time: 01/11/2013 10:58:22
If you're still having issues, please email us at Support@Linoma.com or call our Support Help line!
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
4 posts Page 1 of 1