Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  iWay Software Product Forum on Focal Point    Deleting a file from a folder according to a pattern.
Go
New
Search
Notify
Tools
Reply
  
Deleting a file from a folder according to a pattern.
 Login/Join
 
Member
posted
Hi,

I have a folder A which has files like below

File1.txt
File1z.txt
File2z.txt
File3z.txt

How do I delete the files which has a pattern which ends with z.txt and leaving other files as it is.

I tried using the File object with a pattern *z.txt ..
It didn't work..
Is there any other way to acheive this.

Thanks


iWay ISM 5.5/iWay ISM 6.0 on Windows.
 
Posts: 20 | Registered: April 11, 2011Reply With QuoteReport This Post
Expert
posted Hide Post
Can you post the actual code you used, also where are the files, and what happened when you used the code, did it delete all the files, or none, or some ?


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.05OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6110 | Location: Land of the Darug people, Terra Australis Incognita | Registered: October 31, 2006Reply With QuoteReport This Post
Member
posted Hide Post
Hi Waz,



I have the above mentioned files in the path that i have used in the properties and I just built a pflow which includes this FILE(FileOperations)object and ran in the designer,
It runs successfully,but it didn't delete the files.

Thanks


iWay ISM 5.5/iWay ISM 6.0 on Windows.
 
Posts: 20 | Registered: April 11, 2011Reply With QuoteReport This Post
Expert
posted Hide Post
Don't know if I can help much, not an iWay person.

Does the documentation say that wildcards are supported ?


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.05OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6110 | Location: Land of the Darug people, Terra Australis Incognita | Registered: October 31, 2006Reply With QuoteReport This Post
Gold member
posted Hide Post
Hi Gopal,
I suspect that File (from) doesn't accept wild cards. I'm not certain, and can't find anything in the doco.

Have you tried the XDRunCmdAgent? You can issue any command line command from a service object using this. Search info centre for 'run command agent' for details.

Regards,
Ade


iWay 5.5 SMSP1 and 6.0.1 on Intel/Linux
 
Posts: 59 | Location: Birmingham, Blighty | Registered: October 30, 2007Reply With QuoteReport This Post
Gold member
posted Hide Post
I should probably say, you can issue a command to the server command line with this agent, so you could issue:

del D:\XX_Gopal\GK\FilesDelete\*z.txt

and interrogate the return codes passed back from the agent afterwards...


Ade.


iWay 5.5 SMSP1 and 6.0.1 on Intel/Linux
 
Posts: 59 | Location: Birmingham, Blighty | Registered: October 30, 2007Reply With QuoteReport This Post
Member
posted Hide Post
Thanks for the reply AdeH,

But when I execute a simple p-flow with the service XDRunCmdAgent and with the command mentioned by you
del D:\XX_Gopal\GK\FilesDelete\*z.txt,

P-flow fails to execute with the error,
error : Detected problem in agent execute: java.io.IOException: CreateProcess: del D:\XX_Gopal\GK\FilesDelete\*z.txt error=2


iWay ISM 5.5/iWay ISM 6.0 on Windows.
 
Posts: 20 | Registered: April 11, 2011Reply With QuoteReport This Post
Gold member
posted Hide Post
Hi Gopal,
This works fine for me if I use an SREG to hold the command I'm issuing... set an SREG to have the value:
del D:\XX_Gopal\GK\FilesDelete\*z.txt

Then reference that SREG in your XDRunCmdAgent property runcmd.cmd.label. I left all other properties of the agent as default - platform, false, false, 0, false, false.

Give that a try.
AdeH


iWay 5.5 SMSP1 and 6.0.1 on Intel/Linux
 
Posts: 59 | Location: Birmingham, Blighty | Registered: October 30, 2007Reply With QuoteReport This Post
Member
posted Hide Post
Had your issue been solved Gopal?Just let me know..
 
Posts: 1 | Location: Pacific Crt Kelowna, BC | Registered: September 26, 2011Reply With QuoteReport This Post
Member
posted Hide Post
Hi Adeh,

Thanks for your time.

Even I tried giving the exact file path and this also giving me the same error.

del D:\XX_Gopal\GK\FilesDelete\File3.txt

Service object :-- run variable holds the value del D:\XX_Gopal\GK\FilesDelete\File3.txt.

RunCmdAgent object uses this SREG(run)in runcmd.cmd.label property and all others being default.

This is what the error that I am getting,

error status="1">
   <msg>Exception returned from OS</msg>
   <exception type="java.io.IOException">
      <emsg>Cannot run program "del": CreateProcess error=2, The system cannot find the file specified</emsg>


P-flow is very simple,

I really dont know what is causing this error,is that to do with the access???
or because I am running the p-flow directly from the designer??

As of now I am executing a script directly from a command prompt,as it accepts the wild cards and have made this as a scheduled task.


iWay ISM 5.5/iWay ISM 6.0 on Windows.
 
Posts: 20 | Registered: April 11, 2011Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Something like this might do the trick:
 
-SET &APP = 'baseapp';
 APP FI DELPROC DISK delproc.fex
 APP QUERY &APP HOLD
 TABLE FILE FOCAPPQ 
 PRINT COMPUTE APPDEL/A200 = 'APP DELETEFILE &APP "' | GETTOK(FILENAME,70,1,'.',70,'A70') || '" TXT';
 WHERE FILENAME LIKE '%z.txt' 
 ON TABLE SET HOLDLIST PRINTONLY
 ON TABLE HOLD AS DELPROC FORMAT ALPHA 
 END 
-RUN 
-IF &RECORDS EQ 0 THEN GOTO DONE;
 EX DELPROC
-DONE
 

Change the &APP to the one of your choice.
This is not OS specific and avoids explicit looping commands such as -REPEAT.
Use the WHERE statement to select files for deletion.
You can comment out the ON TABLE HOLD line to see the code being generated.
Handle with care, you wouldn't want to accidentally wipe out a bunch of files.


WF 8.2.06
Win10 / IE11
AHTML EXL2K PDF
 
Posts: 138 | Registered: October 19, 2010Reply With QuoteReport This Post
Member
posted Hide Post
Try D:\\XX_Gopal\\GK\\FilesDelete\\File3.txt.


iWay Service Manager (6.0.1 - patch.62627)
DMC Version 7 Release 7
 
Posts: 12 | Registered: January 24, 2011Reply With QuoteReport This Post
Gold member
posted Hide Post
I would raise a case with IBs info response about your initial issue with the file object.

AdeH


iWay 5.5 SMSP1 and 6.0.1 on Intel/Linux
 
Posts: 59 | Location: Birmingham, Blighty | Registered: October 30, 2007Reply With QuoteReport This Post
Gold member
posted Hide Post
Hi,
Silly question really, but can you issue the command 'del D:\XX_Gopal\GK\FilesDelete\File3.txt' from your command line? I'm thinking either you're not on windows, so DEL isn't the correct keyword for deleting files, or maybe it's a permissions problem?
Can you try running your pflow from a listener/channel in iSM? I've seen plenty of differences between that and test running in designer in the past...

Ade


iWay 5.5 SMSP1 and 6.0.1 on Intel/Linux
 
Posts: 59 | Location: Birmingham, Blighty | Registered: October 30, 2007Reply With QuoteReport This Post
Member
posted Hide Post
Hi Adeh,

Yes, I can able to delete from the command line.

As the designer didn't work out,I am executing a script directly from a command prompt,as it accepts the wild cards and have made this as a scheduled task,that checks and deletes the files everyday.

Previously I was running the p-flow directly from designer,But I have to try the channel option.


iWay ISM 5.5/iWay ISM 6.0 on Windows.
 
Posts: 20 | Registered: April 11, 2011Reply With QuoteReport This Post
Expert
posted Hide Post
Could this be a security issue ?


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.05OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6110 | Location: Land of the Darug people, Terra Australis Incognita | Registered: October 31, 2006Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  iWay Software Product Forum on Focal Point    Deleting a file from a folder according to a pattern.

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.