Solved

Copy/Insert folder/s to the same root directory (of the same depth)

Posted on 2014-04-14
3
277 Views
Last Modified: 2014-04-17
I have a Terminal Server with Windows Server 2003 and would like to implement a specific folder structure and force the users to stick to it. Problem comes in when creating new folders... If you grant the user the right to edit the structure you loose control all over again, but I am not prepared to add the same folder for 1000s of clients in the structure manually.

Is there a way that I can add/create the same folder in multiple  "Tax" subfolders for example. In the image attached I explained the structure: I have an existing clientfolder with multiple client folders, each client has multiple entities, but in each entity the folder structure remains the same. I would like to add the folder "2013" in red in the image to all the existing "Tax" folders at once.

I've searched for software, but could find none that could actually do what I want (explained above). There are software that can create folder structures or even copy existing structures like File Boss and 47 Folders.

I wondered if I could create a batch file to create these folders simultaneously?
DIRECTOR.gif
0
Comment
Question by:Bizfolio
  • 2
3 Comments
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 39998916
A simple batch script should do the trick; just set the search root to the actual path of the client folders, and save as Whatever.cmd. The script is currently in test mode and will only display the "md" commands it would normally run, so that you can test it. To run it for real, remove the uppercase "ECHO" in line 9.
@echo off
setlocal
set SearchRoot=D:\Client Folders
set SearchFolder=Tax
set AddFolder=2013
for /f "delims=" %%a in ('dir /s /b /a:d "%SearchRoot%\%SearchFolder%"') do (
	echo Processing '%%a' ...
	if not exist "%%a\%AddFolder%" (
		ECHO md "%%a\%AddFolder%"
		echo ... added folder '%AddFolder%'.
	) else (
		echo ... folder '%AddFolder%' already exists.
	)
)

Open in new window

0
 
LVL 83

Expert Comment

by:oBdA
ID: 39998917
A simple batch script should do the trick; just set the search root to the actual path of the client folders, and save as Whatever.cmd. The script is currently in test mode and will only display the "md" commands it would normally run, so that you can test it. To run it for real, remove the uppercase "ECHO" in line 9.
@echo off
setlocal
set SearchRoot=D:\Client Folders
set SearchFolder=Tax
set AddFolder=2013
for /f "delims=" %%a in ('dir /s /b /a:d "%SearchRoot%\%SearchFolder%"') do (
	echo Processing '%%a' ...
	if not exist "%%a\%AddFolder%" (
		ECHO md "%%a\%AddFolder%"
		echo ... added folder '%AddFolder%'.
	) else (
		echo ... folder '%AddFolder%' already exists.
	)
)

Open in new window

0
 

Author Closing Comment

by:Bizfolio
ID: 40006122
This worked like a charm. Thank you very much. It is a simple and very effective solution.
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Suggested Solutions

A short article about problems I had with the new location API and permissions in Marshmallow
Learn about cloud computing and its benefits for small business owners.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now