2
我正在嘗試完成一項家庭作業腳本編寫任務,對此我一直沒有任何意見,需要查找/研究腳本的修復。我需要運行的腳本查看三列(名稱,ID,部門)文件(我給出的),並假設應該創建新的組和用戶,並將用戶分配到正確的組。每個組只能創建一次。我的問題是使用帶有標記的FOR/f命令。腳本練習
文件1個
@ECHO OFF
SET /p userfFile="what is the file that contains new hires: "
REM Loop through the lines of the file
REM and copy the the department names to a new file
FOR /f "tokens=3 skip=4" %%b IN (%userfFile%) DO ECHO %%b >> Department.txt
REM sort the file back into itself
sort Department.txt /0 Department.txt
REM a variable to keep track of the groups that have neen created
SET LastGroupCreated=None
FOR /f %%a IN (Department.txt) DO CALL CUG
FOR /f "tokens=2,3 skip=4" %%A IN (%userfFile%) DO CALL
REM Clean Up
DEL Department.txt
SET userfFile=
檔案2 「CUG」
REM Have we already processed this name (%1) ?
IF "%LastGroupCreated%"=="%1" GOTO :EOF
REM Not Processed, so create and update the variable
NET LOCALGROUP /ADD %1
SET LastGroupCreated=%1
我相信文件CUG是好的,但文件中的一個不斷給我的錯誤。如果有人能幫助我,我會非常感激。我已經試過,我能想到的一切,我堅持
乾杯
詹姆斯
什麼錯誤? –