Hi,
I want to extract a certain substring in my file path. For example, if I have C:\Downloads\Subfolder1\file.pdf and C:\Downloads\Subfolder2\file.pdf then I want to extract Subfolder1\file.pdf and Subfolder2\file.pdf. Is there any way for me to do this?
Hi @upnewbie
Yes. It is possible.
Below is the workflow for the same.
Main.xaml (19.0 KB)
Output :-
Mark as solution and like it
Happy Automation
Best Regards
Er Pratik Wavhal
1 Like
Thank you Also, is there a way for me to remove the Downloads in this string for example, but keep the other parts? So C:\Subfolder1\file.pdf instead of C:\Downloads\Subfolder1\file.pdf
ppr
(Peter Preuss)
July 25, 2020, 2:43pm
4
Have a Look on .net functions and classes
Path
WE do habe Options Like getfilename, …
And The class directoryinfo
Getdirectories
Hi @upnewbie
So the download Keyword will be static always or any other keyword may also der present in the path ??
If its gonna be same all the time then forget the above workflow and do the below thing.
Do all the things inside Assign activity :-
String str = “C:\Downloads\Subfolder2\file.pdf”
str = str.Replace(“\Downloads”,“”)
Output :-
Mark as solution and like it
Happy Automation
Best Regards
Er Pratik Wavhal
1 Like
Thank you, that is exactly what I wanted
Hi @upnewbie
You are welcome
Happy Automation
Best Regards
Er Pratik Wavhal
lokendra
(lokendra)
July 25, 2020, 3:26pm
8
Hi
You can use regex, Split, or replace.
For Example:
Split(strinput.ToString,”C:\Downloads\”)(1).ToString.Trim
System.Text.RegularExpressions.Regex.Match(strinput.ToString,”(?<=C:\Downloads).*(\d)”).ToString.Trim
strinput.Replace(“C:\Downloads",”")
1 Like
system
(system)
Closed
July 28, 2020, 3:26pm
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.