Delete Specific Files in Remote File List

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

GA_Forum

Posts: 11
Joined: Mon Nov 10, 2014 3:05 pm

Post by GA_Forum » Mon Apr 13, 2015 9:58 am
I have a project that connects to a server and retrieves multiple files. On the get command I have a processed source files variable called "RemoteFiles". After the files are retrieved they are placed into a workspace. The project goes on to check the files that were retrieved (and are now in the workspace) to see if they have a footer record or not. If a file does have a footer record, then at the end of the project I want to delete that file from the remote server. If the file does not have a footer record, then I do not want to delete it from the remote server. Since all files that were retrieved from the remote server are included in the "RemoteFiles" file list (created on the get command), I cannot use ${RemoteFiles} as the input files variable in the delete command. How do I specify which files I want to delete?

For example, say I have the following two files in my RemoteFiles variable.
"/incoming/processing files/filename1.txt"
"/incoming/processing files/filename2.txt"

Say only file "filename2.txt" contains a footer record so I want to delete that file from the remote server. How would I do that?

I am using GoAnywhere Director version 4.6.2 and Windows Server 2012 operating system.

Thank you for any suggestions!

Support_Rick

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

Post by Support_Rick » Fri Apr 24, 2015 12:16 pm
When processing the LOCAL files to check for footer records, I would assume you're doing this through a "For-each" loop. As you are processing these files and you identify the file as having a Footer Record, using your PRINT Task, write out the file information into a CSV file inside your Temp Workspace. Something like ...
Code: Select all
ForEach ${LocalFiles} -> ThisFile
Have Footer?
   	<print file="FilesToDelete.csv" append="true" version="1.0">
			<![CDATA[${ThisFile:name}${system.carriageReturn}]]>
		</print>
/ForEach

ReadCSV FilesToDelete.csv -> FilesToDelete

ForEach ${FilesToDelete} -> DelFile
   Sftp <Remote Server> Persistent = YES
      Delete ${DelFile[1]}
/ForEach
This should help you get close to your desired process.
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696

GA_Forum

Posts: 11
Joined: Mon Nov 10, 2014 3:05 pm

Post by GA_Forum » Thu May 14, 2015 2:10 pm
Thank you for the suggestion Rick, it worked like a charm!
3 posts Page 1 of 1