none
Moving files using VBScript

    Question

  • I have a folder that contains more folders. In those folders are files. I need all those files to be moved to 1 single folder. I need a script that will do that. The problem is there are 535 folders. They all have the same name just a different number like Example1,Example2 all the way to Example535. I just need to know how I can create a script that will move each file out of the folders to my destination folder.
    Wednesday, March 21, 2012 5:52 PM

Answers

  • Hi,

    My advice is to use the robocopy command with the /move option. In this way there is no need for a script.

    Bill

    Wednesday, March 21, 2012 7:04 PM
    Moderator
  • I have a folder that contains more folders. In those folders are files. I need all those files to be moved to 1 single folder. I need a script that will do that. The problem is there are 535 folders. They all have the same name just a different number like Example1,Example2 all the way to Example535. I just need to know how I can create a script that will move each file out of the folders to my destination folder.

    I recommend using POwerShell.  YOU can eaily enumerte the contents of all folders and move the file.  If you are moving to a different drive then I recommend foing a copy and delete.  This will protect the files in case of a failure.  If the efiles all move correctl then upi can delete the originals.

    Here is the PosH code to do this:

    dir f:\projects\scripts -recurse |
         Where{$_.PSIsContainer}|
         ForEach{
            dir *|
            Where{!$_.PSIsContainer}
         }|
         ForEach{copy $_ e:\scripts2\}


    ¯\_(ツ)_/¯

    Wednesday, March 21, 2012 7:20 PM

All replies

  • So I read the info. What should I do?

    I don't know how to keep the concatenation going? Or how to set it up.

    Wednesday, March 21, 2012 6:02 PM
  • What should I do?

    Hi,

    I would recommend starting to learn scripting. If you have a script already that isn't doing what you need, you can ask for help with that. But we really don't have the resources to write your script for you. Please remember that the other forum participants are (with the exception of a very few people) not Microsoft employees who volunteer to help for free.

    Bill

    Wednesday, March 21, 2012 6:04 PM
    Moderator
  • I apologize if you think I'm trying to take advantage or use people. I am truly not doing that. Maybe if someone can just point me in the right direction. This is the script I have. Very basic way to move 1 file to another folder. If someone can just explain how I can keep the function reoccuring through a folder till it empties it contents. Even somewhere I can read it. I just was asked to do the task by my boss and I am just trying to learn the process not just feed off others. I tried reading EVERYTHING I could find. The forum was something I tried avoiding.

    Option Explicit
    Dim fso


    Set fso = CreateObject("Scripting.FileSystemObject")

    fso.MoveFile "C:\Test 1\*", "C:\Test 2\"


    • Edited by Jayburna688 Wednesday, March 21, 2012 6:14 PM
    Wednesday, March 21, 2012 6:13 PM
  • Hi,

    My advice is to use the robocopy command with the /move option. In this way there is no need for a script.

    Bill

    Wednesday, March 21, 2012 7:04 PM
    Moderator
  • I have a folder that contains more folders. In those folders are files. I need all those files to be moved to 1 single folder. I need a script that will do that. The problem is there are 535 folders. They all have the same name just a different number like Example1,Example2 all the way to Example535. I just need to know how I can create a script that will move each file out of the folders to my destination folder.

    I recommend using POwerShell.  YOU can eaily enumerte the contents of all folders and move the file.  If you are moving to a different drive then I recommend foing a copy and delete.  This will protect the files in case of a failure.  If the efiles all move correctl then upi can delete the originals.

    Here is the PosH code to do this:

    dir f:\projects\scripts -recurse |
         Where{$_.PSIsContainer}|
         ForEach{
            dir *|
            Where{!$_.PSIsContainer}
         }|
         ForEach{copy $_ e:\scripts2\}


    ¯\_(ツ)_/¯

    Wednesday, March 21, 2012 7:20 PM
  • Thanks for the help i am trying it now!
    Wednesday, March 21, 2012 7:32 PM