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

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,211 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
[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: 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

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…
Many businesses neglect disaster recovery and treat it as an after-thought. I can tell you first hand that data will be lost, hard drives die, servers will be hacked, and careless (or malicious) employees can ruin your data.
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
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…

730 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