Solved

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

Posted on 2013-10-23
2
1,166 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 84

Accepted Solution

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

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Test the speeds on my PC Drives 12 62
Large File Sharing For Business 7 39
Setting up RAID5 on HP ProLiant DL380G5 15 71
Batch: reboot servers one by one. 4 22
The question appears often enough, how do I transfer my data from my old server to the new server while preserving file shares, share permissions, and NTFS permisions.  Here are my tips for handling such a transfer.
Microsoft will be releasing the Windows 10 Creators Update in just a matter of weeks. Are you prepared? Follow these steps to ensure everything goes smoothly and you don't lose valuable data on your PC.
This video teaches viewers how to encrypt an external drive that requires a password to read and edit the drive. All tasks are done in Disk Utility. Plug in the external drive you wish to encrypt: Make sure all previous data on the drive has been …
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…

840 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