Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Move Profile Subfolders to new location

Posted on 2016-08-31
2
Medium Priority
?
57 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 85

Accepted Solution

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

Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

705 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