cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Utilize copy service to transfer file WITHOUT overwriting

AT_10111928
3-Visitor

Utilize copy service to transfer file WITHOUT overwriting

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.

1 ACCEPTED SOLUTION

Accepted Solutions
slangley
23-Emerald II
(To:PaiChung)

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

View solution in original post

4 REPLIES 4
PaiChung
22-Sapphire I
(To:AT_10111928)

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.

slangley
23-Emerald II
(To:PaiChung)

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

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!

PaiChung
22-Sapphire I
(To:AT_10111928)

Although performance wise just as fast or close you can use InfoTable Functions Query as well vs. looping.

Top Tags