UNZIP - If a file exists ... Skip option

Hi

Is there a way to skip existing files if the file exists as opposed to the current options I see of Abort or overwrite?

Thanks

Hi @piashaw,

i think the try/catch nodes in combination with the abort option might do what you want (cannot test at the moment)

Else you would have to check for your self if the file alread exists and the logic what to do
e.g. with a list files and a switch node

1 Like

*just checked - the try/catch option does what you want (at least if I understand you correctly)
skip unzip.knar (10.5 KB)

2 Likes

Hello @piashaw,

although @AnotherFraudUser provided solution I have created ticket (Internal reference: AP-15080) to add Skip option to Unzip Files node.

Have a nice day,
Ivan

2 Likes

Thanks.

I think it would be a useful option for others too.

Sorry for the delay. Thanks I will try that our now. I need to learn exactly how these try-catch nodes work. Unfortunately I must not understand it properly or at least how to use it in a loop.
Skip unzipped files.knwf (16.9 KB)

In the workflow I need to read a directory with multiple zip files. I then use the output of the List Files node as the input for a loop and in that loop it unzips all the files into their smaller text files. After that I read the text files and carry on with the analysis.

I tried to add the try and catch within the loop but however I tried it always failed.

Every day a new Zip file is created and I may have a few 100 of them so I’m trying to stop the unzipping process as quickly as possible At the moment I have it set to overwrite so at least I end up with everything unzipped.

Well you could employ an R node and use that and set the unzip command to ignore already existing files.

https://www.rdocumentation.org/packages/utils/versions/3.6.2/topics/unzip

An example how r and zip can be used.

1 Like

Thanks, appreciate it!
what I don’t get is why the catch is returning the same output on both variable ports? According to the doc that should not be the case or am I missing something?

Hi @Daniel_Weikert,

the catch block will always return the upper incomming path of there is no error.
If there is an error the lower incomming path will be filled.
Additionally the error message will be returned.

What exactly does not work? :thinking:

Hi @piashaw,

will check out your example tomorrow (or the day after tomorrow)
But effectively it should work within a loop without any problems :thinking:

When I use the node it returns the same output on both ports no matter if a failure occurs or not. That’s strange to me

Hi @piashaw,

your workflow is just fine.

However you cannot use the “Loop End” Node with input from the failing node!
If you use the variable loop end node - then your loop works just fine :slight_smile:

*so replace your Loop End Node with the Variable Loop End Node and it should work :slight_smile:
If you want to output of the non-failing Unzip-Nodes - then you have to use the Catch Error (data Ports) Node!

I think this also is the reason for your it does not fill the error variables - as you did not really catch the error. (the error in the Unzip Node was catched) but not the one in the Loop End node

2 Likes

Many thanks indeed. All working now. I never knew there were so many loop end nodes!!

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

@piashaw,

an option to ignore existing files will be made available with the new version of this node as part of the 4.3 release.

Best
Mark

Note the new node is called Decompress rather than Unzip

6 Likes