I am looking for a quick way to copy data from one location to multiple user profile locations on the server share. The only change in the destination path is the username.
我正在寻找一种快速方法将数据从一个位置复制到服务器共享上的多个用户配置文件位置。目标路径中唯一的更改是用户名。
I want to target specific users, and those user ID are in a text file.
我想定位特定用户,并且这些用户ID位于文本文件中。
Can I loop though this list replacing the username in the path and make the copy?
我可以通过此列表循环替换路径中的用户名并制作副本吗?
I can do this the long way either manual copy, or create hundreds of lines, and changing the username for each copy using the below command
我可以通过手动复制或创建数百行来完成此操作,并使用以下命令更改每个副本的用户名
XCOPY C:\Shortcuts\* \\Server\Share\%USERNAME%\Profile\Favorites\Shortcuts /s /I
Many thanks
1 个解决方案
#1
1
Sounds easy. Let's assume you want to copy X:\someDir
to Y:\%USERNAME%\someDir
using any user name listed in a text file (user_list.txt
or something) as %USERNAME%.
听起来很容易。假设您要使用文本文件(user_list.txt或其他内容)中列出的任何用户名将X:\ someDir复制到Y:\%USERNAME%\ someDir为%USERNAME%。
FOR /F %%U IN (user_list.txt) DO (
XCOPY X:\someDir Y:\%%U\someDir /E /Y /I
)
This should work as long as your user names don't contain special characters.
只要您的用户名不包含特殊字符,这应该有效。
#1
1
Sounds easy. Let's assume you want to copy X:\someDir
to Y:\%USERNAME%\someDir
using any user name listed in a text file (user_list.txt
or something) as %USERNAME%.
听起来很容易。假设您要使用文本文件(user_list.txt或其他内容)中列出的任何用户名将X:\ someDir复制到Y:\%USERNAME%\ someDir为%USERNAME%。
FOR /F %%U IN (user_list.txt) DO (
XCOPY X:\someDir Y:\%%U\someDir /E /Y /I
)
This should work as long as your user names don't contain special characters.
只要您的用户名不包含特殊字符,这应该有效。