Ilogic move and rename parts

Ilogic move and rename parts

Anonymous
Not applicable
2,054 Views
5 Replies
Message 1 of 6

Ilogic move and rename parts

Anonymous
Not applicable
I have a part file XXXXYYYY.ipt and I would like an ilogic code that searches if my file name contains "XXXXYYYY" to replace the X's and Y's with 1244SIMS and moves that file to a specified folder. Is there any code out there that will allow me to do this?
0 Likes
Accepted solutions (1)
2,055 Views
5 Replies
Replies (5)
Message 2 of 6

Vladimir.Ananyev
Alumni
Alumni

You may consider the huge set of methods in the .NET String class to change filename.

Look at these links:

String Class
http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.strings.aspx?cs-save-lang=1&cs-lang=vb...

Strings in Visual Basic
http://msdn.microsoft.com/en-us/library/hzcd8ze0.aspx

 

You may use
ThisDoc.Document.SaveAs(NewFileNameAndExtension , SaveCopyAs)
method to save the file with another filename.

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 6

Anonymous
Not applicable

Thanks for the quick reply and info. Now, that I have a basic understanding of strings how do I tell my renamed file what path to take? I want my renamed file to save to a certain directory.

0 Likes
Message 4 of 6

Vladimir.Ananyev
Alumni
Alumni

Assume
1) the new filename is MyNewFile.ipt
2) you want to save your renamed file to the existing folder   d:\AAA\BBB\CCC\DDD

then your rule could be similar to the following:

'new filename
dim Filename as string = "MyNewFile.ipt"
'target folder path
dim DirName as string = "d:\AAA\BBB\CCC\DDD"
'now you may create the full filename
dim FullFilename as string = DirName & "\" & Filename
'save file
ThisDoc.Document.SaveAs(FullFilename , False)

See also System.IO.Path class details.
Very useful if you need to perform operations on strings that contain file or directory path information.

http://msdn.microsoft.com/en-us/library/system.io.path.aspx


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 5 of 6

Anonymous
Not applicable

Thanks that worked but how do I delete the old folder once my file has been moved?

0 Likes
Message 6 of 6

Vladimir.Ananyev
Alumni
Alumni
Accepted solution

My advice - use .NET System.IO namespace objects.

In this particular case - Directory.Delete(...) method
http://msdn.microsoft.com/en-us/library/system.io.aspx

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network