1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Batch Folder Copy

Discussion in 'DOS/Other' started by jojopolo, Aug 1, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. jojopolo

    jojopolo Thread Starter

    Joined:
    Aug 1, 2012
    Messages:
    3
    Hello, I have a situation where I need to copy over a certain named file and the folder its located in from C: to D: from a group of folders and subfolders. The directories are setup like below. The main project folder it is located in will always have a variable name but the group1 folder will always be named that. I need only the menu file and its folders its located in from group1. Below I have also shown how I need it outputted. Any help would be appreciated. thanks

    C: DIR Project1
    SUBDIR group1
    menu
    other files
    SUBDIR group2
    menu
    other files
    SUBDIR group3


    DIR Project2
    SUBDIR group1
    menu
    other files
    SUBDIR group2
    menu


    DIR Project3
    SUBDIR group1
    menu
    other files
    SUBDIR group5
    SUBDIR group6
    menu
    other files


    The way I would like it outputted

    D: DIR Project1
    SUBDIR group1
    menu

    DIR Project2
    SUBDIR group1
    menu

    DIR Project3
    SUBDIR group1
    menu
     
  2. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,731
    I am not really understanding your current directory structure. A better way to show that example would have been to use the TREE command from the a cmd prompt.

    Is this what your project folders look like?
    Edit: Right now the code tags are not working correctly so I had to use Quote tags and it doesn't ident the directory structure correctly. The file names in my output should all be indented underneath their respective group folders.
     
  3. jojopolo

    jojopolo Thread Starter

    Joined:
    Aug 1, 2012
    Messages:
    3
    Yes that is correct how you have displayed it. I will have multiple variable named project folders but with same folder and file structure below it as the one you have listed. The MENU file does not have an extension on it though, it's not a text file. I need it to output just the project folder, the group1 folder inside the project folder, and the menu file inside the group1 folder. My thoughts were to use a batch file to copy over all the folders that have a menu file and then have a second command to delete the folders that I do not need. Maybe there is an easier way just to copy over the the project folder, group1 folder, and menu file only. Below is what I have started with. The second command removes the whole project folder instead of just removing all the other group folders except for group1 so there is something not quite right with it. Thanks for all your help.

    robocopy c:\ *menu* d:\ /s /dcopy:t
    pushd "d:\"
    FOR /F "tokens=*" %%G IN ('DIR /S *group2*') DO RMDIR /S /Q %%G
     
  4. jojopolo

    jojopolo Thread Starter

    Joined:
    Aug 1, 2012
    Messages:
    3
    I figured it out myself. Here is the answer if anybody is interested in the future.

    robocopy c:\ *menu* d:\ /s /dcopy:t
    for /D %%I in ("d:\*") do For %%J in (group2 group3 group4 group5 group6) do rmdir /s/q "%%I\%%J"
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1063471