Solved

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

Posted on 2014-04-14
3
290 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 84

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 84

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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Learn about cloud computing and its benefits for small business owners.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

733 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