1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Moving multiple folders with a batch file

Discussion in 'Windows - General discussion' started by jerecho, Feb 4, 2009.

  1. jerecho

    jerecho Regular member

    Joined:
    Nov 23, 2005
    Messages:
    697
    Likes Received:
    0
    Trophy Points:
    26
    Can someone tell me what the line command is so I can move multiple folders and files in another folder. Basicly tell it to move all folders and files inside a specific folder. Say I have a folder on my desktop named 1. Now I want all folders and files in that folder moved without having to list all of the folders because these folder names will change on a daily basis
     
  2. Mez

    Mez Active member

    Joined:
    Aug 12, 2005
    Messages:
    2,895
    Likes Received:
    9
    Trophy Points:
    68
    If you do not specify a name how is the computer to know what to do? I do not believe you can move a folder and subfolders they way you would like to do it.

    You could experiment using the xcopy command. That will copy a folder X with the subfolders. I have not written a batch file in many years I do not now if batch files/or the DOS window supports long file names. I also forget, you may be able to name the target or you can always rename the target folder maybe with a name passed to the batch file as a parameter. Then you would have to go into the folder X and delete *.*. That will accomplish the same thing. It is also safer if you trap write errors and exit out before the delete if an error occurs.
     
  3. vballstud

    vballstud Guest

    Code:
    @echo off
    copy "FULL PATH TO FOLDER OF FILES BEING COPIED" "FULL PATH OF DESTINATION FOLDER"
    XP DOS prefers you to use full paths within quotation marks, unlike old DOS where each folder was only 8 characters and didn't like spaces.
     
    Last edited by a moderator: Feb 4, 2009
  4. jerecho

    jerecho Regular member

    Joined:
    Nov 23, 2005
    Messages:
    697
    Likes Received:
    0
    Trophy Points:
    26
    I can get it to copy folders and subfolders just fine. Just can't move the folders the way I want to. Oh well guess I'm screwed. Thanks for the responces
     
  5. vballstud

    vballstud Guest

    So basically you're cutting and pasting instead of just copying?
    Replace "copy" with "move".
     
    Last edited by a moderator: Feb 4, 2009
  6. ucfmoe

    ucfmoe Regular member

    Joined:
    Mar 17, 2007
    Messages:
    130
    Likes Received:
    0
    Trophy Points:
    26
    I believe the command is

    xcopy "source" "destination" /E /T

    but i could be wrong, google xcopy commands, or you could use RoboCopy
     
  7. PatMc9

    PatMc9 Member

    Joined:
    Apr 8, 2009
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    11
    Jerecho. If you want to move all files and sub-folders (at any level) from one folder to another folder, use the following commands in biterscripting. Here, the 'from' folder is C:/folder1, the 'to' folder is C:/folder2.

    Code:
    # Get a list of files and subfolders within C:/folder1.
    var str list ; find -n "*" "C:/folder1" > $list
    # Move each file and subfolder in the list to C:/folder2.
    while ($list <> "")
    do
        var str item ; lex "1" $list > $item
        system move $item "C:/folder2"
    done
    For automating things like this, especially when files/folders are created dynamically, and you don't know their names ahead of time, biterscripting turns out to be very helpful. Download it free at http://www.biterscripting.com/install.html . For example, if you want only to move files/folders created after Feb 3, 2009, add the following to the find command.

    Code:
    ($fctime > "20090203")

    PatrickMc
     

Share This Page