Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

DOS/Other DOS/Other
Search Search
Search for:
Tech Support Guy > > >

Solved: Batch Folder Copy


(!)

jojopolo's Avatar
jojopolo jojopolo is offline
Member with 3 posts.
THREAD STARTER
 
Join Date: Aug 2012
01-Aug-2012, 06:12 PM #1
Solved: Batch Folder Copy
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's Avatar
Trusted Advisor with 19,656 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
02-Aug-2012, 07:05 AM #2
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?
Quote:
H:\>tree Project1 /f
Folder PATH listing for volume DATA
Volume serial number is D2F3-49FA
H:\PROJECT1
├───group1
│ foo1.txt
│ foo2.txt
│ menu.txt

├───group2
│ foo1.txt
│ foo2.txt
│ menu.txt

└───group3
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.

Last edited by Squashman; 02-Aug-2012 at 07:15 AM..
jojopolo's Avatar
jojopolo jojopolo is offline
Member with 3 posts.
THREAD STARTER
 
Join Date: Aug 2012
02-Aug-2012, 01:42 PM #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
jojopolo's Avatar
jojopolo jojopolo is offline
Member with 3 posts.
THREAD STARTER
 
Join Date: Aug 2012
29-Aug-2012, 04:06 PM #4
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

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑