Consulting

Results 1 to 3 of 3

Thread: Solved: Simple way of moving all files in a folder

  1. #1
    VBAX Regular
    Joined
    Mar 2009
    Location
    Stowmarket
    Posts
    62
    Location

    Solved: Simple way of moving all files in a folder

    Here is some very simplistic code that doesn't work ... I have looked around this site and others and there appear to be some very complicated ways of doing what I want to do ... is there a simple way ?!?!?

    [vba]MkDir ("E:\MyLeagueOld)

    Name "E:\MyLeague\*.txt" As "E:\MyLeagueOld\*.txt"
    Name "E:\MyLeague\*.pdf" As "E:\MyLeagueOld\*.pdf"
    Name "E:\MyLeague\*.xls" As "E:\MyLeagueOld\*.xls"
    Name "E:\MyLeague\*.doc" As "E:\MyLeagueOld\*.doc"[/vba]

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    [VBA]ChDrive "E"
    MkDir "E:\MyLeagueOld"
    Shell "cmd /c move /y " & _
    """" & "E:\MyLeague\*.txt" & """" & " " & _
    """" & "E:\MyLeagueOld" & """", vbHide[/VBA]

    Change /c to /k and vbHide to vbNormalFocus if you want to see the results.

    We could have used Dir() to iterate the folder's file names and used Name.
    Last edited by Kenneth Hobs; 04-01-2009 at 11:44 AM.

  3. #3
    VBAX Regular
    Joined
    Mar 2009
    Location
    Stowmarket
    Posts
    62
    Location
    Brilliant, thanks Kenneth ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •