Solved

Move Profile Subfolders to new location

Posted on 2016-08-31
2
50 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
[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 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

Technology Partners: 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

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

739 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