Solved

Move Profile Subfolders to new location

Posted on 2016-08-31
2
33 Views
Last Modified: 2016-08-31
We have a profile repository D:\Profiles\*username*

Is it possible to script the MOVE of two partiuclar folders under the above directory to a new location using the same *username* parent folder?

Example

D:\Profiles\jsmith\Downloads              MOVE TO                           D:\Profiles_Old\jsmith\Downloads

Having to do this for over 400 profiles, so automation and keeping the target folder under a parent folder with the username would be great
0
Comment
Question by:Daniel Diaz
2 Comments
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 41778765
This should do the trick; it's in test mode and will only report what it would do.
Remove the uppercase ECHOs in lines 12 and 14 to run it for real.
@echo off
setlocal
set Source=D:\Profiles
set Target=D:\Profiles_Old
set FolderList=Downloads Foo
for /d %%a in ("%Source%\*") do (
	echo Processing %%~nxa ...
	for %%f in (%FolderList%) do (
		echo   - %%~f ...
		if exist "%%a\%%~f" (
			if not exist "%Target%\%%~nxa" (
				ECHO md "%Target%\%%~nxa"
			)
			ECHO move "%%a\%%~f" "%Target%\%%~nxa"
		) else (
			echo     ... not found.
		)
	)
)

Open in new window

1
 

Author Comment

by:Daniel Diaz
ID: 41778815
Worked like a charm.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

19 Experts available now in Live!

Get 1:1 Help Now