Replace a portion of the filename using iLogic

Replace a portion of the filename using iLogic

Jason_Aloot
Participant Participant
445 Views
6 Replies
Message 1 of 7

Replace a portion of the filename using iLogic

Jason_Aloot
Participant
Participant

Good day.

I want to achieve on how to replace a portion of a part filename.
Example:
Before:
12345_PART1.ipt

After:
67890_PART1.ipt


0 Likes
Accepted solutions (2)
446 Views
6 Replies
Replies (6)
Message 2 of 7

Jason_Aloot
Participant
Participant

To make it clear.. I want to replace the filename in the iProperties.

0 Likes
Message 3 of 7

A.Acheson
Mentor
Mentor
Accepted solution

Are you replacing the file or just modifying the description /part number? Either way you can use string functions to isolate the section of the string that will change. Split could work here targeting the underscore. Microsoft examples are here and ilogic example here.

 

Post up an attempt and forum members can help out if you get stuck. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 4 of 7

Jason_Aloot
Participant
Participant

Thanks for your quick reply. I am modifying the description on the iProperties.

I will look at the example links you provided. thanks again.

0 Likes
Message 5 of 7

william
Advocate
Advocate
Accepted solution

here's one example from a rule I use regularly to modify solid body names. I tweaked it slightly for your use with iProperties. 

strDescription_Original = iProperties.Value("Project", "Description")

strFindText = InputBox("Enter the text to be replaced" & vbNewLine & "Description: " & strDescription_Original, "iLogic Find-Replace", FindText)
strReplaceText = InputBox("Replace With", "iLogic Find-Replace", ReplaceText)

strDescription_New = Replace(strDescription_Original, strFindText, strReplaceText)
iProperties.Value("Project", "Description") = strDescription_New

 
Another one could be

strDescription_Original = iProperties.Value("Project", "Description")

strDescription_Array = strDescription_Original.Split("_")
'strDescription_ArrayCount = UBound(strDescription_Array)
strVariable1 = strDescription_Array(0)

strReplaceText = InputBox("Enter Description Field 1", "iLogic Find-Replace", "####")
strDescription_New = Replace(strDescription_Original, strVariable1, strReplaceText)
iProperties.Value("Project", "Description") = strDescription_New

MessageBox.Show("Description: " & iProperties.Value("Project", "Description"), "Title")

 

0 Likes
Message 6 of 7

Jason_Aloot
Participant
Participant
thanks. This helps indeed!

I modified the part number instead of the description.
0 Likes
Message 7 of 7

Jason_Aloot
Participant
Participant
This helps mo too to modify the code. cheers!
0 Likes