Solved

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

Posted on 2014-04-14
3
287 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A quick step-by-step overview of installing and configuring Carbonite Server Backup.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

809 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