Solved moving files using partial names (1 Viewer)

follower2020

New member
Local time
Today, 19:22
Joined
May 14, 2020
Messages
9
hello everyone

If i have many pdf files with names say :

999 jane
999jane
999 jane d

I want to move all the files starting with 999 to a specific folder
I am getting error in this part : Name "C:\Users\Modhy\Desktop\Scanner\" & Me.Casenumber & "" & "*.pdf"

what is wrong with this part ( Me.Casenumber & "" & "*.pdf" )

casenumber is the 999

Thank you
 

ebs17

Well-known member
Local time
Today, 18:22
Joined
Feb 7, 2020
Messages
1,949
Code:
    Dim sPath As String
    Dim sNewPath As String
    Dim sFile As String

    sNewPath = "X:\AnyWhere\XY"

    sPath = "X:\AnyWhere\"              
    sFile = Dir(sPath & "999*.pdf")                    
    Do While sFile > vbNullString                  
        'Debug.Print sFile                          
        Name sPath & sFile As sNewPath & "\" & sFile

        sFile = Dir                                
    Loop
Other ways of moving would be using xcopy or robocopy.
 
Last edited:

follower2020

New member
Local time
Today, 19:22
Joined
May 14, 2020
Messages
9
Dear ebs17

Great. Thank you for your assistance.

I have tested it.
 

Users who are viewing this thread

Top Bottom