# Solved: Batch Folder Copy



## jojopolo (Aug 1, 2012)

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


----------



## Squashman (Apr 4, 2003)

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?


> H:\>tree Project1 /f
> Folder PATH listing for volume DATA
> Volume serial number is D2F3-49FA
> H:\PROJECT1
> ...


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.


----------



## jojopolo (Aug 1, 2012)

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


----------



## jojopolo (Aug 1, 2012)

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"


----------

