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
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!
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 Specialist
- Posts: 590
- Joined: Tue Jul 17, 2012 2:12 pm
- Location: Phoenix, AZ
-
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
This should help you get close to your desired process.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
Rick Elliott
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
Lead Solutions Consultant
(402) 944.4242
(800) 949-4696
3 posts
Page 1 of 1