Luca_Smith
(Luca Smith)
October 12, 2023, 10:51am
1
Good morning everyone,
I can’t use regular formulas
I have all the files containing:
Work09Document2022”se_meta”:9001
Work09Document2022”se_meta”:9002
Work09Document2022”se_meta”:9003
Work09Document2022”se_meta”:9004
Work09Document2022”se_meta”:9005
.
.
.
(and so on)
I basically have to look for initials
(Wildcard)“se_meta”:90
And I have to replace
Work09Document2023”se_meta”:90
Thanks for your help
Roberto Grigis
Gokul001
(Gokul Balaji)
October 12, 2023, 10:55am
2
Hi @Luca_Smith
Have you tried with Rename Files
Regards
Gokul
Luca_Smith
(Luca Smith)
October 12, 2023, 11:15am
3
Thanks Gokul001,
no rename the file…
but replace inside the file.
supriya117
(Supriya Allada)
October 12, 2023, 11:19am
4
Hi @Luca_Smith
Try this:
Read Text File
For Each item in Collection
item = System.Text.RegularExpressions.Regex.Replace(item, "Work09Document2022""se_meta"":90[0-9]+", "Work09Document2023""se_meta"":90")
Append Text File (if needed)
1 Like
Hi @Luca_Smith ,
Could you maybe explain a bit more as to what is required, the provided requirement is not very understandable.
Do you want to perform a renaming of the file ?If so, Example after the renaming is done would help us provide proper suggestions.
Luca_Smith
(Luca Smith)
October 12, 2023, 11:40am
6
For the REGEX program or also NOTEPAD++
Thanks and best regards
Luca_Smith
(Luca Smith)
October 12, 2023, 11:44am
7
Thanks for the reply, what you wrote, what program was it from?
supriya117
(Supriya Allada)
October 12, 2023, 11:47am
8
@Luca_Smith
Use for each to iterate through file names
Use assign activity to replace the file name using regex.
item = System.Text.RegularExpressions.Regex.Replace(item, "Work09Document2022""se_meta"":90[0-9]+", "Work09Document2023""se_meta"":90")
rlgandu
(Rajyalakshmi Gandu)
October 12, 2023, 11:49am
9
@Luca_Smith
Assign searchString = “se_meta":90”
Assign replaceString = “Work09Document2023"se_meta":90”
Assign directoryPath = “path_to_your_directory”
Assign filePaths = Directory.GetFiles(directoryPath)
For Each filePath In filePaths
Assign fileContents = File.ReadAllText(filePath)
Assign fileContents = fileContents.Replace(searchString, replaceString)
File.WriteAllText(filePath, fileContents)
End For Each
Luca_Smith
(Luca Smith)
October 12, 2023, 11:54am
10
supriya117:
Use for each to iterate through file names
Use assign activity to replace the file name using regex.
item = System.Text.RegularExpressions.Regex.Replace(item, "Work09Document2022""se_meta"":90[0-9]+", "Work09Document2023""se_meta"":90")
I don’t understand what program you use?
lrtetala
(Lakshman Reddy)
October 12, 2023, 4:12pm
12
Hi @Luca_Smith
Welcome to Community!!
Please check the below xaml
BlankProcess12.zip (45.4 KB)
O/P:
Hope this helps!!
Luca_Smith
(Luca Smith)
October 13, 2023, 8:29am
13
lrtetala:
Hope this helps!!
Thanks for your kind help
but I don’t know how to use xaml, please explain to me in detail why I don’t know that extension.
Thank you
lrtetala
(Lakshman Reddy)
October 13, 2023, 8:40am
14
@Luca_Smith
->For Each File in Folder
->Read Text File
->TextFile=System.Text.RegularExpressions.Regex.Replace(TextFile.ToString, ".*""se_meta"":90", "Work09Document2023""se_meta"":90")
->Write Text File
Main.xaml (11.7 KB)
Luca_Smith
(Luca Smith)
October 13, 2023, 9:03am
15
Sorry Main.xaml where do you open from?
I don’t see how you attached the image?
Is there any software?