Page 1 of 1

file properties

Posted: Wed Oct 26, 2016 8:01 am
by ehersh
Is it possible to use a file list and write the contents of that list to an excel spreadsheet? Specifically they want the file name and last date modified in the spreadsheet as 2 columns.

Re: file properties

Posted: Wed Oct 26, 2016 8:06 am
by Support_Rick
Yes,

Just loop through the FileList variable (ForEach). This gives you access to each of the file attributes (Name, Size, LastModifiedDate, etc). Write them out to a temporary CSV file in the Workspace.

When finished looping, read the CSV file into a RowSet, then write the RowSet into the Excel.

Re: file properties

Posted: Wed Oct 26, 2016 8:28 am
by ehersh
It does look like I would have to set up a rowset first correct?

Re: file properties

Posted: Wed Oct 26, 2016 8:32 am
by Support_Rick
Not sure what you mean by "setup a Rowset first" ...

Just "print" the file information into a CSV file in the Workspace. Then, read the CSV when you're done. This creates the RowSet (reading the CSV) that you can write out to your Excel

Re: file properties

Posted: Mon Jan 30, 2017 3:45 pm
by ehersh
I was finally able to get back to this project. Thanks Rick it does work. The desired result here is to get a list of files from a directory and e-mail them to the sender to confirm we got the files. I just thought I would share the code. Also if anyone has suggestions to improve efficiency I always try to listen.
Code: Select all
<<project name="Test_email" mainModule="Main" version="2.0" logLevel="verbose">

	<module name="Main">

		<createWorkspace version="1.0" />


		<createFileList label="create e-mail list" fileListVariable="filelist" numFilesFoundVariable="filecnt" version="1.0" disabled="false">
			<fileset dir="<path to>/Eligibility/test2" />
		</createFileList>

		<forEachLoop itemsVariable="${filelist}" currentItemVariable="currentfile" disabled="false">

			<print file="<path to>/test/filelist.csv" append="true" version="1.0" disabled="false">
				<![CDATA[${currentfile:name} ${system.carriageReturn}]]>
			</print>

		</forEachLoop>

		<sendEmail resourceId="mail.wonderboxtech.com" toList="[email protected]" version="2.0" disabled="false">
			<from address="Scion_Dental" />
			<message file="<path to>/Eligibility/test/filelist.csv">
				<![CDATA[The following files were sent today:

]]>
			</message>
			<subject>
				<![CDATA[files sent today ]]>
			</subject>
		</sendEmail>


		<delete file="<path to>/Eligibility/test/filelist.csv" version="1.0" disabled="false" />


		<deleteWorkspace version="1.0" />

	</module>

</project>