我收到了我的一批并且效果非常好!!
我只想补充一点。我的一些客户在 C 盘根目录下有文件夹。我怎样才能让批处理文件将他们添加的整个文件夹拖放到我需要的位置,而不拖走“程序”、“驱动程序”等文件夹?
场景:客户端有 3 个文件夹,分别名为“个人 1”、“个人 2”和“个人 3”,但还有其他系统文件夹,分别名为“驱动程序”、“程序文件”、“图标”、“WINNT”等……有没有办法让我只提取“个人 1”、“个人 2”和“个人 3”,而不必为每个文件夹创建一个全新的行?那样就毫无意义了。谢谢!
My Batch File
set /p targetuser="Enter target username: "
xcopy /s/z F:\"Documents and Settings"\%targetuser%\Desktop D:\"Documents and
Settings"\%username%\Desktop
xcopy /s/z F:\"Documents and Settings"\%targetuser%\Favorites D:\"Documents and Settings"\%username%\Favorites
xcopy /s/z F:\"Documents and Settings"\%targetuser%\"My Documents" D:\"Documents and Settings"\%username%\"My Documents"
xcopy /s/z F:\"Documents and Settings"\%targetuser%\Recent D:\"Documents and Settings"\%username%\Recent
xcopy /s/z F:\"Documents and Settings"\%targetuser%\NetHood D:\"Documents and Settings"\%username%\NetHood
xcopy /s/z F:\"Documents and Settings"\%targetuser%\PrintHood D:\"Documents and Settings"\%username%\PrintHood
xcopy /s/z F:\"Documents and Settings"\%targetuser%\Templates D:\"Documents and Settings"\%username%\Templates
xcopy /s/z F:\"Documents and Settings"\%targetuser%\"Start Menu" D:\"Documents and Settings"\%username%\"Start Menu"
xcopy /s/z F:\"Documents and Settings"\%targetuser%\"Local Settings"\"Application Data"\Microsoft\Outlook D:\"Documents and Settings"\%username%\"Local Settings"\"Application Data"\Microsoft\Outlook
pause
更多信息:我的批处理文件几乎都是标准文件夹。有些客户端在 C 盘中有非标准文件夹,就像这张照片中的那样。
我怎样才能使批处理文件包含所有文件夹“data”、“fun”和“go”,而不在批处理中添加任何行?“xcopy /s/z C:\Data D:\” 这样做太耗时间了。
是否有我可以告诉批处理文件不要拉取的文件?比如“program files”或 winnt。抱歉,我是批处理文件的新手。如果您不完全理解,请见谅。
答案1
使用 RoboCopy!请参阅robocopy /?
帮助。
@echo off
set /p "targetuser=Enter target username: "
:: Your xcopy statements here. These too can be converted into using robocopy.
:: This will copy from C: into D: including subdirectories, ignoring all files and ignoring the specified folders.
robocopy "C:\" "D:\" /s /mt /xf *.* /xd "C:\Program Files" "C:\Drivers" "C:\WinNT" "C:\Icons"
pause