Batch file for moving files to folder?

Page 1 of 2 12 LastLast

  1. Posts : 246
    7 Prof
       #1

    Batch file for moving files to folder?


    Hello,
    Wanted to see if any one here wouldn't mind writing a batch file or script that would move multiple files to a target folder. Here are the specifics:
    HDD1 Contains Folders A,B,C,etc...
    Folder A contains Folder A1 which contains File A2
    Folder B contains Folder B1 which contains File B2
    Folder C contains Folder C1 which contains File C2
    Folder D contains Folder D1 which contains File D2
    Folder E contains Folder E1 which contains File E2
    Folder F contains Folder F1 which contains File F2

    And what I need to do is move A2,B2,...F2.. to the drive root.

    This would really save some time over moving these files manually, because they're numerous.
    Or if you know of any utilities that can do this, please let me know
    Thanks.
      My Computer


  2. Posts : 4
    Windows 7
       #2

    I am assuming that these all folders are in X drive

    such that your file A2.xxx is in X:\Folder A\Folder A1

    move "X:\Folder A\Folder A1\File A2.xxx" X:\
    move "X:\Folder B\Folder B1\File B2.xxx" X:\
    move "X:\Folder C\Folder C1\File C2.xxx" X:\
    move "X:\Folder D\Folder D1\File D2.xxx" X:\
    move "X:\Folder E\Folder E1\File E2.xxx" X:\
    move "X:\Folder F\Folder F1\File F2.xxx" X:\
    save it as bat file.
    If you are using windows 7 than open the file in Administrator mode.

    I hope it will help
      My Computer


  3. Posts : 23
    Win 7 RC, Win XP, Win 2003, Ubuntu
       #3

    Another alternative to do it:

    for %s in (A B C D E F) do move "x:\Folder %s\Folder %s1\File %s2.xxx" x:\

    That's assuming you type it at the command line. If you put it in a .BAT file, make every % in the line above %%.
      My Computer


  4. Posts : 246
    7 Prof
    Thread Starter
       #4

    Thanks for the suggestions. The problem here is that A B C D ... are really long folder names and there are tons of those folders. It simply isn't practical to have to list the actual folder names. I'm looking for something that just dumps all the elements of all folders out to root.
      My Computer


  5. Posts : 2,737
    Windows 7 Enterprise (x64); Windows Server 2008 R2 (x64)
       #5

    First off it is never and I mean never good to copy files to the root of any drive. Especially C: (if that is your OS drive). It would be much better to move them to X:\MovedFiles or something like that.

    Is there some sort of pattern to the folders off the root? Or are you moving everything from all folders off the root? If this is on your C: Drive the script would move everything from the C: drive including Windows (that is if the OS did not protect itself) but it would do a lot of damage. If all the folders are on another drive that would be best, but again if there is no pattern it will be hard to move files without moving files you don't mean to.

    Let me know.
      My Computer


  6. Posts : 23
    Win 7 RC, Win XP, Win 2003, Ubuntu
       #6

    If there isn't a pattern, how about non-move folders? There can't be all that many of those. You could do a dir c:\ /ad/b >folderlist.txt at the command line then open folderlist.txt in notepad and search for the folders you don't want moved and remove those lines. Save the file then you can do a for /f and use the .txt as the input source for the folder list to move.
      My Computer


  7. Posts : 23
    Win 7 RC, Win XP, Win 2003, Ubuntu
       #7

    PS, what is the file extension of the files you want dumped in root? If it's something odd that will only exist in those special folders an easy solution would be:

    for /f "tokens=*" %s in ('dir x:\*.weirdextn /s/b') do move "%s" x:\

    I also agree with WindowsStar though.. it's usually not prudent to just dump all that stuff to root.
      My Computer


  8. Posts : 17
    Windows7 Ultimate 64 bit
       #8

    I used n2ncopy in the past and it works very good.
      My Computer


  9. Posts : 246
    7 Prof
    Thread Starter
       #9

    Strahan said:
    PS, what is the file extension of the files you want dumped in root? If it's something odd that will only exist in those special folders an easy solution would be:

    for /f "tokens=*" %s in ('dir x:\*.weirdextn /s/b') do move "%s" x:\

    I also agree with WindowsStar though.. it's usually not prudent to just dump all that stuff to root.
    This might work. I'll give it a try later on. There are altogether about 15 types of files accross all folders, so a much simpler solution would be a search for file types in the drive (not C drive btw) and just move them, albeit 15 times.
      My Computer


  10. Posts : 23
    Win 7 RC, Win XP, Win 2003, Ubuntu
       #10

    Cool. Another alternative to automate it to cover your varied filetypes:

    for %s in (ext1 ext2 ext3 ext4) do for /f %t in ('dir x:\*.%s /s/b') do move "%t" x:\

    That way you only have to type in the exts once and it does the relocations automatically.
      My Computer


 
Page 1 of 2 12 LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 03:13.
Find Us