Solved

Move Profile Subfolders to new location

Posted on 2016-08-31
2
48 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 84

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 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