Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-04-14
3
Medium Priority
?
304 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 85

Accepted Solution

by:
oBdA earned 2000 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 85

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 Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
Make the most of your online learning experience.
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…
Six Sigma Control Plans

783 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