I am using an expression to process only specific files form a folder but i want to process only the files which start with PAN_, CHEQUE_, GST_ Can anyone please help me with this?
Below are the screenshots
Hi @Seema_Jethe ,
try below code
Directory.GetFiles(@"c:\MyDir", “PAN_", SearchOption.AllDirectories)
Directory.GetFiles(@"c:\MyDir", "CHEQUE_”,SearchOption.AllDirectories)
Directory.GetFiles(@"c:\MyDir", “GST_*”, SearchOption.AllDirectories)
or
Directory.GetFiles("C:\\MyDir", "*.*", SearchOption.AllDirectories)
.Where(s => s.StartWith("PAN_") || s.StartWith("CHEQUE_") || s.StartWith("GST_"))
Regards,
Arivu
Try this
Directory.GetFiles("C:\\MyDir", "*.*", SearchOption.AllDirectories) .Where(s => s.StartWith("PAN_") || s.StartWith("CHEQUE_") || s.StartWith("GST_"))
Regards,
Arivu
try this in single line
Directory.GetFiles(“C:\MyDir”, “.”, SearchOption.AllDirectories) .Where(s => s.StartsWith(“PAN_”) || s.StartsWith(“CHEQUE_”) || s.StartsWith(“GST_”))
Try this:
Assign Activity:
strArrVariable = Directory.GetFiles(“FolderPath”, “.”, SearchOption.AllDirectories).Where(function(s) path.GetFileName(s).StartsWith(“PAN_”) and path.GetFileName(s).StartsWith(“CHEQUE_”) and path.GetFileName(s).StartsWith(“GST_”) and s.EndsWith(“.pdf”) and s.EndsWith(“.jpg”)).ToArray
Thanks!
@kadiravan_kalidoss i tried your expression but it does not work i am getting null value in variable using assign activity
Try below code
VB.net
Directory.GetFiles("C:MyDir", ".", SearchOption.AllDirectories).Where(Function(s) s.StartsWith("PAN_") OrElse s.StartsWith("CHEQUE_") OrElse s.StartsWith("GST_"))
or
c#
Directory.GetFiles("C:\MyDir", ".", SearchOption.AllDirectories) .Where(s=> s.StartsWith("PAN_") || s.StartsWith("CHEQUE_") || s.StartsWith("GST_"));
Regards,
Arivu
Hi @Seema_Jethe ,
Try the below expression. it was working at my end. thanks.
Hi,
Try with the below expression. it was working at my end.
Expression.txt (170 Bytes)
@kirankumar.mahanthi1 will your expression process the files starting with PAN_ , CHEQUE_, GST_ as i need only the files with names as PAN_xx.pdf or jpg, CHEQUE_xx.pdf or jpg or GST_xx.pdf or jpg and not files like xxx_PAN.pdf or jpg
i have tried with few samples only. Could you test with your files in Realtime and let us know. thanks.
Hi @Seema_Jethe,
I have modified the condition and tested. Its working as expected. Please try this code below.
StringArrayVariable = Directory.GetFiles(“FolderPath”, “.”, SearchOption.AllDirectories).Where(function(s) (path.GetFileName(s).StartsWith(“PAN_”) or path.GetFileName(s).StartsWith(“CHEQUE_”) or path.GetFileName(s).StartsWith(“GST_”)) and (s.EndsWith(“.pdf”) or s.EndsWith(“.jpg”))).ToArray
Thanks!