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

x
?
Solved

Robocopy "Home Directory" script.  Need help getting the first letter of a user name.

Posted on 2013-10-23
2
Medium Priority
?
1,218 Views
Last Modified: 2013-10-23
I need a simple script (Powershell, batch, vb) that will robocopy the first letter of the folder to the destination file server.

For example.  I'd like to take all the user's folders from the source directory with first initial "a" and copy it over to a specified path on another server.

Please help!
0
Comment
Question by:tools2teach
2 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 2000 total points
ID: 39594640
Put a loop around robocopy; the following script is in test mode and will only display the robocopy commands it would normally run. Remove the uppercase ECHO in line 8 to run it for real (and configure the robocopy options you want in the Filter variable)
@echo off
setlocal enabledelayedexpansion
set SourceFolder=C:\Temp
set TargetFolder=D:\Temp
set Filter=A*
set RCOptions=/e /np /r:0 /w:0
for /d %%a in ("%SourceFolder%\%Filter%") do (
	ECHO robocopy.exe "%%a" "%TargetFolder%\%%~nxa" %RCOptions%
)

Open in new window

0
 

Author Closing Comment

by:tools2teach
ID: 39594752
Awesome.....this was what I was looking for.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Concerto Cloud Services, a provider of fully managed private, public and hybrid cloud solutions, announced today it was named to the 20 Coolest Cloud Infrastructure Vendors Of The 2017 Cloud  (http://www.concertocloud.com/about/in-the-news/2017/02/0…
Is your phone running out of space to hold pictures?  This article will show you quick tips on how to solve this problem.
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…
Suggested Courses

926 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