Move pdf files to new folder

Move pdf files to new folder

Anonymous
Not applicable
1,023 Views
4 Replies
Message 1 of 5

Move pdf files to new folder

Anonymous
Not applicable

anyone help out with some illogic that will move all pdf files from one folder to another?

 

Thanks in adavance

 

0 Likes
1,024 Views
4 Replies
Replies (4)
Message 2 of 5

MechMachineMan
Advisor
Advisor

If you are writing in vb.net, I recommend you check out the MSDN website; ie google: "move files + MSDN + vb.net".

 

You might also have luck just googling it without the MSDN as stackoverflow often has a ton of good information.

 

I've written functions that do this before so it's definitely easily possible.


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 5

Anonymous
Not applicable

thanks Justin, I've invested 2+ hours in google searches already prior to posting. I have a workaround in place (not as pretty) but will invest another hour or two over the weekend.

 

cheers!

0 Likes
Message 4 of 5

MechMachineMan
Advisor
Advisor

http://lmgtfy.com/?q=mdsn+%2B+vb.net+%2B+move+files&l=1

 

As you see here, it provides the File.Move method.

 

In order to use this, you either need to:

                a) add "Imports System.IO" to the top of your program OR

                b) call it as: System.IO.File.Move(sourcefilename, desitnationfilename).

 

That tough. Shouldn't have taken 2 hours (took me <50 seconds). Hopefully this will save you some time next time you need to look things up!


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 5 of 5

Anonymous
Not applicable

Hope this Vba code might helpful for you to move the pdf files to another folder

 

Sub Move_Pdf_Files()
'This example move the Pdf Files from FromPath to ToPath.
    Dim FSO As Object
    Dim FromPath As String
    Dim ToPath As String
    Dim FileType As String
        FromPath = "F:\New folder\test"  '<< Change
        ToPath = "F:\New folder\test1"    '<< Change
        If Right(FromPath, 1) = "\" Then
            FromPath = Left(FromPath, Len(FromPath) - 1)
        End If
    
        If Right(ToPath, 1) = "\" Then
            ToPath = Left(ToPath, Len(ToPath) - 1)
        End If
    
        Set FSO = CreateObject("scripting.filesystemobject")
    
        If FSO.FolderExists(FromPath) = False Then
            MsgBox FromPath & " doesn't exist Please create the folder First"
            Exit Sub
        End If
        Set Folder = FSO.GetFolder(FromPath)
        For Each Filename In Folder.Files
            FileType = Right(Filename, 3)
            If FileType = "pdf" Then
                oFilename = FSO.GetFileName(Filename)
                ToFileName = ToPath & "\" & oFilename
                FileCopy Filename, ToFileName
                Filename.Delete
            End If
        Next
End Sub
0 Likes