Skip to main content
1-Visitor
March 25, 2022
Solved

Utilize copy service to transfer file WITHOUT overwriting

  • March 25, 2022
  • 1 reply
  • 1609 views

I know this is probably a simple question, but I've been stuck on this for hours. I have a service configured to copy a large file over to all things that fit a certain criteria (software version), but I need some sort of if/else statement to check if the file is already there, and not copy the file again if it already exists. I cannot figure out how to check if the file exists. Help would be greatly appreciated!

 

Edit: My first approach was to run a browse directory service, return that as an intotable, then make an if then statement checking if the filename I'm looking for was included. But I since found out the .includes does not work in TW. Ideas?

 

Thank you.

Best answer by slangley

Hi @AT_10111928.

 

As Pai stated, you can you use the GetDirectoryStructure and GetFileListing to obtain the list of files.  There are also a number of filters available on the platform side you can use for filtering available in Services under Resources > InfoTableFunctions.  It's recommended that you review the list available as there are several services that may fit your needs.

 

Regards.

 

--Sharon

1 reply

22-Sapphire I
March 29, 2022

If you are using a ThingWorx Edge Agent, I believe it should come with a GetDirectoryStructure and GetFileListing (or the like) services.

It's been a very long time since I did anything though with our agent.

slangleyCommunity ManagerAnswer
Support
April 6, 2022

Hi @AT_10111928.

 

As Pai stated, you can you use the GetDirectoryStructure and GetFileListing to obtain the list of files.  There are also a number of filters available on the platform side you can use for filtering available in Services under Resources > InfoTableFunctions.  It's recommended that you review the list available as there are several services that may fit your needs.

 

Regards.

 

--Sharon

1-Visitor
April 8, 2022

Got it, thank you! The piece I was missing was automating the search. I created a for loop that checks the returned file list for a matching file name. The part I wasn't sure how to do was the for loop; returning the file list was the easy part, it was finding a way to automate the file search that I was struggling with. But I got it taken care of, thank you!