- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello fellows Inventor experts!
I am here again looking for your help to try to solve an issue.
I have searched here in this forum and on the internet, I found some information about it, but not specific that helped me to achieve my target.
Here is my goal: I have a form created to standard an operation performed repeatedly in a manually way.
I don’t know very much about ilogic, but I think that it is possible to build this form.
I need help to place some buttons, fields and create the illogic codes.
The buttons and fields I need to create are:
• One field to input some values;
• One button that load a dialog box that allowed the user to select a folder where some files will be pasted. These files are templates and your origin will be always the same, but the destination will be always different;
• One button to start the copy of files;
I imagine that these will be the main steps, in details:
1 – Create a field to input the Project number;
2 – Create a button to load a dialog box. This button should be similar to the image 2 in the file attached;
3 – Load a dialog box like shown in the file attached – image 3 (I think it’s a standard dialog box in windows);
4 – Create a button (image 4) to start the copy of files to the folder indicated in the image 3
The name of the files pasted should contain the values informed in the Project Number shown in the image 1 and other standard values;
5 – Show a pop-up message informing that the creation of new files were successfully.
I have created the illustrations attached in other office programs, to explain in the best way I could.
I appreciate the help of the colleagues.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Would this form be a local iLogic form (saved within the document), a Global iLogic form, or a VBA UserForm?
- If local, what type of Inventor file would it be in?
- How do you want to trigger this form to show? (manually, parameter change, file new, file open, file close, other)
- Where in this process are you selecting the files that are going to be copied? I see were you mention selecting a destination folder, where some files will be pasted to, but not where you are selecting the files in the first place.
Wesley Crihfield
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
have a look at the following iLogic code. it's not exact what you asked for but i think it is what you want. It makes a copy of the active document. Also it sets the iproperty Project to the project number that was given.
I added 2 comments in the code. At the first it allowes you to set a template file name. The other shows you where you can add extra iProperties to set.
Dim projectNumber = InputBox("What is the project numebr", "Project number", "") Dim folderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog() Dim path As String = "" If (folderBrowserDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then path = folderBrowserDialog1.SelectedPath Else Return End If Dim doc As Document = ThisApplication.ActiveDocument Dim fileInfo As System.IO.FileInfo = New System.IO.FileInfo(doc.FullFileName) ' Replace the text test in the next line with something meaning full for you Dim newFileName As String = String.Format("test {0} test{1}", projectNumber, fileInfo.Extension ) Dim newFullFileName As String = System.IO.Path.Combine(path, newFileName ) System.IO.File.Copy(fileInfo.FullName, newFullFileName, True ) Dim newDoc As Document = ThisApplication.Documents.Open(newFullFileName) newDoc.PropertySets("Design Tracking Properties")("Project").Value = projectNumber ' set more properies here if you want newDoc.Save() Dim res = MessageBox.Show("File is created. do you want to close it?", "File created" ,MessageBoxButtons.YesNo) If (res = DialogResult.Yes) Then newDoc.Close() End If
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello @JelteDeJong!
First of all, thank you very much for your reply.
I will start answering your questions:
Would this form be a local iLogic form (saved within the document), a Global iLogic form, or a VBA UserForm?
If local, what type of Inventor file would it be in?
This form will be a local iLogic form (saved within the document). The Inventor version where this form will be used is a 2018 – Professional.
How do you want to trigger this form to show? (manually, parameter change, file new, file open, file close, other)
The trigger will be a button in the section iLogic>Forms> the name will be something like Show form.
Where in this process are you selecting the files that are going to be copied? I see were you mention selecting a destination folder, where some files will be pasted to, but not where you are selecting the files in the first place.
This local will be always the same. Could be a sub folder in the same folder where this file with this form is saved, or we can specify by ourselves an appropriated local that help create the code more simple.
It is a group of files (almost 11). I don’t desire the user indicate the files that should be copied, I would like this command to be done by the iLogic code.
I have tested your code and is a huge step in the correct direction.
Just need a few adjusts to achieve may target and together we can succeed.
01 – The files I need to past and rename, is not the one is open. They are other files, a pack, of files saved in the same location where this file that contain the form is saved. Will be almost 11 files.
02 – The rename process, should use the sequential number inputted in the dialog box. This sequential number should replace some part of the templates files name after pasted it.
The template files already have part of the names correct that should be remain.
For example:
Template file name: XXX – YYYY Internal plate
Final name after the file be pasted: 101 – 2020 Internal plate
Where, “101 – 2020” are the values I have inputted in the dialog box
The idea is just input the sequential number once in dialog box and the iLogic code will put correct names in all 11 files.
Feel free for any question or comments.
Once again, thank you very much for the help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Some more questions..
- like @WCrihfield asked, is the form an assembly or a part document?
- if the template file name is "xxx - yyyy internal plate" can we always cut the first 10 charakters to get " internal plate" and then the new values in front?
regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello! Fullevent thanks for join us in this case.
About your questions:
The form will be accessed from an assembly file.
Actually, the part that will be modified in the name is not in the beginning of the name, is in the middle.
The final name will be like show below
DEPT-YYYY-XXX-01-1 INTERNAL PLATE. Where the begin “DEPT” and the part “01-1” will be always the same when these files were created.
I think is possible do like you said, cut the first 18 characters to get the name of piece and then put the new values in front (considering that part of this name will be always the same and part will be the values from the form).
But the names belong to specific files, is not random.
For example, the content of template file named YYYY-XXX INTERNAL PLATE must be the same content the new file that will be named for example 2020-001 INTERNAL PLATE.
Thanks in advance,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello @fullevent
Attached there is an image simplified to clarifying to you how I imagine, is going to be the steps of copy, paste and rename the files.
The goal is the iLogic code execute the following steps:
The step number one is copy the template files from the origin folder
Step number two is paste the templates files in a folder indicated in the form (like mentioned in the first post)
Step number three is rename the files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello @moraesorlando,
try this VBA-Code. I think its what you want.
Private Sub moraesorlando_KrA()
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
If Not ThisApplication.ActiveDocumentType = kAssemblyDocumentObject Then
MsgBox "No assembly open..", vbCritical, "KrA"
Exit Sub
End If
Dim origin_path As String, new_path As String, user_input As String, tmp_str As String
Dim sFilesToCopy(9) As String
user_input = InputBox("What is the new numebr", "YYYY-XXX", "")
If Len(user_input) <> 8 Then
MsgBox "Invalid input..", vbCritical, "KrA"
Exit Sub
End If
origin_path = Left$(oDoc.FullFileName, InStrRev(oDoc.FullFileName, "\"))
Dim oFileDlg As FileDialog
Call ThisApplication.CreateFileDialog(oFileDlg)
oFileDlg.Filter = "All Files (*.*)|*.*"
oFileDlg.DialogTitle = "Pic file in destination folder"
oFileDlg.InitialDirectory = origin_path
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen
If err Then
MsgBox "User cancelled out of dialog"
Exit Sub
ElseIf oFileDlg.filename <> "" Then
new_path = Left$(oFileDlg.filename, InStrRev(oFileDlg.filename, "\"))
End If
sFilesToCopy(0) = "DEPT-YYYY-XXX-05-01 SUPPORT.ipt"
sFilesToCopy(1) = "DEPT-YYYY-XXX-05-01 SUPPORT.dwg"
sFilesToCopy(2) = "DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.ipt"
sFilesToCopy(3) = "DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.dwg"
sFilesToCopy(4) = "DEPT-YYYY-XXX-03-01 INTERNAL PLATE.ipt"
sFilesToCopy(5) = "DEPT-YYYY-XXX-03-01 INTERNAL PLATE.dwg"
sFilesToCopy(6) = "DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.ipt"
sFilesToCopy(7) = "DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.dwg"
sFilesToCopy(8) = "DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.ipt"
sFilesToCopy(9) = "DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.dwg"
For i = 0 To 9
tmp_str = "DEPT-" & user_input & Right$(sFilesToCopy(i), Len(sFilesToCopy(i)) - 13)
Call ThisApplication.FileManager.CopyFile(origin_path & sFilesToCopy(i), new_path & tmp_str)
Next
MsgBox "I hope you like it", , "Done :)"
End Sub
regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello @fullevent !
Once again, thanks for your help.
I Will, try this code and let you know the results.
Best regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello @fullevent !
I have copied this code and pasted in a new iLogic rule in a assembly file.
After run I received the error message shown in attached file.
Maybe I have done something wrong?
Best regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello @moraesorlando,
it's VBA code not iLogic.
You can use it as a macro or transform it into iLogic.
I hope that is not a problem.
Let me know if you need any help.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
You can copy/paste this snippet into a rule (iLogic).
Hope it works for you.
Dim oDoc As Document
oDoc = ThisApplication.ActiveDocument
If Not ThisApplication.ActiveDocumentType = kAssemblyDocumentObject Then
Messagebox.Show ("No assembly open..", "KrA")
Exit Sub
End If
Dim origin_path As String, new_path As String, user_input As String, tmp_str As String
Dim sFilesToCopy(9) As String
user_input = InputBox("What is the new numebr", "YYYY-XXX", "")
If Len(user_input) <> 8 Then
Messagebox.Show ("Invalid input..", "KrA")
Exit Sub
End If
origin_path = Left$(oDoc.FullFileName, InStrRev(oDoc.FullFileName, "\"))
Dim folderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog()
Dim path As String = ""
If (folderBrowserDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then
new_path = folderBrowserDialog1.SelectedPath
Else
Return
End If
If new_path = "" Then
Messagebox.Show ("User cancelled out of dialog", "KrA")
Exit Sub
End If
sFilesToCopy(0) = "DEPT-YYYY-XXX-05-01 SUPPORT.ipt"
sFilesToCopy(1) = "DEPT-YYYY-XXX-05-01 SUPPORT.dwg"
sFilesToCopy(2) = "DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.ipt"
sFilesToCopy(3) = "DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.dwg"
sFilesToCopy(4) = "DEPT-YYYY-XXX-03-01 INTERNAL PLATE.ipt"
sFilesToCopy(5) = "DEPT-YYYY-XXX-03-01 INTERNAL PLATE.dwg"
sFilesToCopy(6) = "DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.ipt"
sFilesToCopy(7) = "DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.dwg"
sFilesToCopy(8) = "DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.ipt"
sFilesToCopy(9) = "DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.dwg"
For i = 0 To 9
tmp_str = "DEPT-" & user_input & Right$(sFilesToCopy(i), Len(sFilesToCopy(i)) - 13)
Call ThisApplication.FileManager.CopyFile(origin_path & sFilesToCopy(i), new_path & tmp_str)
Next
Messagebox.Show ("I hope you like it", "KrA")
regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Helo @fullevent !
Thanks for generate a code to iLogic, I am new in Inventor programming and not familiar with VBA inside Inventor.
So, I tested the iLogic code but I didn't succeed.
Following, the steps I past through:
1 - I have run the code and a dialog box were shown
2 - I have put the numbers 2020-101
3 - A dialog box for browse the files was shown
4 - I have indicated the destination folder to paste the files
5 - An error message were shown
Please take a look in the attached file with illustrations of each step.
Thanks and best regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Are the files you want to copy in the same directory as your assembly?
Otherwise, I don't know what else it could be..
Or maybe there is something wrong with the file names and you have to adjust.
sFilesToCopy(0) = "DEPT-YYYY-XXX-05-01 SUPPORT.ipt"
sFilesToCopy(1) = "DEPT-YYYY-XXX-05-01 SUPPORT.dwg"
sFilesToCopy(2) = "DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.ipt"
sFilesToCopy(3) = "DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.dwg"
sFilesToCopy(4) = "DEPT-YYYY-XXX-03-01 INTERNAL PLATE.ipt"
sFilesToCopy(5) = "DEPT-YYYY-XXX-03-01 INTERNAL PLATE.dwg"
sFilesToCopy(6) = "DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.ipt"
sFilesToCopy(7) = "DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.dwg"
sFilesToCopy(8) = "DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.ipt"
sFilesToCopy(9) = "DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.dwg"
regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I had a look at the code and I think it's just a missing backslash in the destinationpath that gives the error...
The folderbrowserdialog returns a folderpath without a backslash at the end.
I added it here and I think it should work now.
Dim oDoc As Document oDoc = ThisApplication.ActiveDocument If Not ThisApplication.ActiveDocumentType = kAssemblyDocumentObject Then MessageBox.Show ("No assembly open..", "KrA") Exit Sub End If Dim origin_path As String, new_path As String, user_input As String, tmp_str As String Dim sFilesToCopy(9) As String user_input = InputBox("What is the new numebr", "YYYY-XXX", "") If Len(user_input) <> 8 Then MessageBox.Show ("Invalid input..", "KrA") Exit Sub End If origin_path = Left$(oDoc.FullFileName, InStrRev(oDoc.FullFileName, "\")) Dim folderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog() Dim path As String = "" If (folderBrowserDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then new_path = folderBrowserDialog1.SelectedPath Else Return End If If new_path = "" Then MessageBox.Show ("User cancelled out of dialog", "KrA") Exit Sub End If sFilesToCopy(0) = "DEPT-YYYY-XXX-05-01 SUPPORT.ipt" sFilesToCopy(1) = "DEPT-YYYY-XXX-05-01 SUPPORT.dwg" sFilesToCopy(2) = "DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.ipt" sFilesToCopy(3) = "DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.dwg" sFilesToCopy(4) = "DEPT-YYYY-XXX-03-01 INTERNAL PLATE.ipt" sFilesToCopy(5) = "DEPT-YYYY-XXX-03-01 INTERNAL PLATE.dwg" sFilesToCopy(6) = "DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.ipt" sFilesToCopy(7) = "DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.dwg" sFilesToCopy(8) = "DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.ipt" sFilesToCopy(9) = "DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.dwg" For i = 0 To 9 tmp_str = "DEPT-" & user_input & Right$(sFilesToCopy(i), Len(sFilesToCopy(i)) -13) Call ThisApplication.FileManager.CopyFile(origin_path & sFilesToCopy(i), new_path & "\" & tmp_str) ' Added "\" Next MessageBox.Show ("I hope you like it", "KrA")
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello @JhoelForshav and @fullevent !
Yes this backslash provided good results, but not solve everything.
I still continue receiving the same error message, but now the iLogic code make the copy and renamed correctly two files (see image attached).
I believe now its only necessary some adjusts in the code to achieve the target.
Thanks in advance you two.
Best regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So there is something wrong with the fullfilename of the file which should be copied.
The next file would be this one
sFilesToCopy(2) = "DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.ipt"
please check the spelling. It must be character by character exactly the file name. Maybe there are two spaces or something in the file name.
regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Try this rule. It'll tell you which files it cannot find ![]()
Dim oDoc As Document oDoc = ThisApplication.ActiveDocument If Not ThisApplication.ActiveDocumentType = kAssemblyDocumentObject Then MessageBox.Show ("No assembly open..", "KrA") Exit Sub End If Dim origin_path As String, new_path As String, user_input As String, tmp_str As String Dim sFilesToCopy(9) As String user_input = InputBox("What is the new numebr", "YYYY-XXX", "") If Len(user_input) <> 8 Then MessageBox.Show ("Invalid input..", "KrA") Exit Sub End If origin_path = Left$(oDoc.FullFileName, InStrRev(oDoc.FullFileName, "\")) Dim folderBrowserDialog1 = New System.Windows.Forms.FolderBrowserDialog() Dim path As String = "" If (folderBrowserDialog1.ShowDialog() = System.Windows.Forms.DialogResult.OK) Then new_path = folderBrowserDialog1.SelectedPath Else Return End If If new_path = "" Then MessageBox.Show ("User cancelled out of dialog", "KrA") Exit Sub End If sFilesToCopy(0) = "DEPT-YYYY-XXX-05-01 SUPPORT.ipt" sFilesToCopy(1) = "DEPT-YYYY-XXX-05-01 SUPPORT.dwg" sFilesToCopy(2) = "DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.ipt" sFilesToCopy(3) = "DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.dwg" sFilesToCopy(4) = "DEPT-YYYY-XXX-03-01 INTERNAL PLATE.ipt" sFilesToCopy(5) = "DEPT-YYYY-XXX-03-01 INTERNAL PLATE.dwg" sFilesToCopy(6) = "DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.ipt" sFilesToCopy(7) = "DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.dwg" sFilesToCopy(8) = "DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.ipt" sFilesToCopy(9) = "DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.dwg" For i = 0 To 9 Try tmp_str = "DEPT-" & user_input & Right$(sFilesToCopy(i), Len(sFilesToCopy(i)) -13) Call ThisApplication.FileManager.CopyFile(origin_path & sFilesToCopy(i), new_path & "\" & tmp_str) Catch MessageBox.Show("Please make sure the file: " & origin_path & sFilesToCopy(i) & " exists!", "Couldn't copy file") End Try Next MessageBox.Show ("I hope you like it", "KrA")
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello @JhoelForshav and @fullevent!
I have made two tests first I checked all the names of all the files to search for some spelling mistakes. I built a table in Excel and used a formula to check the spelling, and all the files names are correct with the names in ilogic code (see table below)
| Names in iLogic code without "" | File names | Verification | |
| sFilesToCopy(0) = | DEPT-YYYY-XXX-05-01 SUPPORT.ipt | DEPT-YYYY-XXX-05-01 SUPPORT.ipt | TRUE |
| sFilesToCopy(1) = | DEPT-YYYY-XXX-05-01 SUPPORT.dwg | DEPT-YYYY-XXX-05-01 SUPPORT.dwg | TRUE |
| sFilesToCopy(2) = | DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.ipt | DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.ipt | TRUE |
| sFilesToCopy(3) = | DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.dwg | DEPT-YYYY-XXX-04-01 EXTERNAL PLATE.dwg | TRUE |
| sFilesToCopy(4) = | DEPT-YYYY-XXX-03-01 INTERNAL PLATE.ipt | DEPT-YYYY-XXX-03-01 INTERNAL PLATE.ipt | TRUE |
| sFilesToCopy(5) = | DEPT-YYYY-XXX-03-01 INTERNAL PLATE.dwg | DEPT-YYYY-XXX-03-01 INTERNAL PLATE.dwg | TRUE |
| sFilesToCopy(6) = | DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.ipt | DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.ipt | TRUE |
| sFilesToCopy(7) = | DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.dwg | DEPT-YYYY-XXX-02-01 SIDE LEFT PLATE.dwg | TRUE |
| sFilesToCopy(8) = | DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.ipt | DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.ipt | TRUE |
| sFilesToCopy(9) = | DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.dwg | DEPT-YYYY-XXX-01-01 SIDE RIGHT PLATE.dwg | TRUE |
The result of the second test it's much more interesting.
I ran the code from @JhoelForshav an received the information about issues in all other files (except those two that is working), and clicked ok in each message and as result, all files were copied and renamed correctly to the destination folder. Exactly as we desire.
Looks like the verification lines made by @JhoelForshav does the code reinitiated and copy the files.
I don't understand all lines in the code but I think we are almost there.
Something after the message make the code run correctly.
Maybe is necessary remove the message and keep the verification lines that is working.
Once more thanks you two.
Best regards,