File_List Command

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

File_List Command

Postby MDeVore » Wed Aug 22, 2012 4:22 pm

We have various projects setup which send an e-mail to numerous recipients after moving a file or set of files, depending on the exact project, which reports the name of the files that have been moved. A few different methods for doing this have been experimented with.

Initially we were using a variable along the lines of ${This_File}, which displayed the full file path (something we do not want) until we started adding the :name attribute.
Code: Select all
We have moved ${This_file[1]:name}

However, this method felt clumsy because it required a duplicate variable entry for every file that would be reported as it would only list the files directly referenced.
Code: Select all
We have moved ${This_file[1]:name} ${This_file[2]:name} ${This_file[3]:name}

So I started trying to use File_List to do this instead, which worked perfectly for the basic process and simplified things a bit, but again displayed the full file path. So I attempted adding the :name attribute here as well, but File_List seems to act the same as This_File when :name is added, and it displays the first file within the list when you do ${File_List[1]:name}

Am I missing something simple here to give one or both of these commands a wild card? Or is there some better method of using File_List so that it will list all of the files within the list without their path?
Posts: 8
Joined: Tue Aug 07, 2012 3:22 pm

Re: File_List Command

Postby Support_Rick » Wed Aug 22, 2012 5:27 pm

Can you post an example of what you want to see when the Project is run?

If you're wanting to see a "list" of files moved in the email without the file path, then you will have to create a Variable and loop through the FileList appending the name of the file ${File:name} to the variable, then printing the list at the end.

Code: Select all
   These files have been Moved by GoAnywhere


This could be done with the following code:

Code: Select all
<createFileList label="Get FileList" fileListVariable="Files" numFilesFoundVariable="NoFiles" version="1.0">
   <fileset dir="${ MyDIR }" recursive="true">
         <include to="${ CutOffDate }" />

<setVariable label="Init FileList" name="FileList" value="${ system.emptyString }" version="1.0" />

<forEachLoop label="List Files" itemsVariable="${Files}" currentItemVariable="ThisFile">
    <setVariable label="Update FileList" name="FileList" value="${ FileList }${ system.carriageReturn }${ ThisFile:name }" version="1.0" />
    <move label="Move Doc" sourceFile="${ ThisFile }" destDir="${ NewDIR }" whenFileExists="overwrite" version="1.0" />

<sendEmail label="Send Notification" resourceId="MyResource" toList="" version="2.0">
   <from address="" />
      <![CDATA[ These files have been Moved by GoAnywhere ]]>
      <![CDATA[ ${ FileList } ]]>

*NOTE* ${ MyDir } is a Variable set to the Directory you want to get the File List from. ${ CutOffDate } is used in this example for identifying a specific group of Files within ${ MyDir }

If there are any questions, please feel free to let us know.

Rick Elliott
Sr. Product Specialist
(402) 944.4242
(800) 949-4696
Support Specialist
Posts: 225
Joined: Tue Jul 17, 2012 2:12 pm

Re: File_List Command

Postby MDeVore » Thu Aug 23, 2012 7:32 pm

Greatly appreciated sir. This part in particular was precisely what I was trying to do.

Code: Select all
<createFileList fileListVariable="fileList" numFilesFoundVariable="listCount" version="1.0">
         <fileset dir="myDIR" />

      <setVariable name="sourceList" value="${system.emptyString}" version="2.0" />

      <forEachLoop itemsVariable="${fileList}" currentItemVariable="thisFile">

         <setVariable name="sourceList" value="${sourceList}${system.carriageReturn}${ThisFile:name} " version="2.0" />

Posts: 8
Joined: Tue Aug 07, 2012 3:22 pm

Return to Community Forum

Who is online

Users browsing this forum: No registered users and 0 guests