Batch Command Delete dan Copy

script batch command berikut adalah untuk menghapus seluruh isi folder kecuali file atau folder tertentu:

@ECHO OFF
SETLOCAL
SET "sourcedir=U:\sourcedir"
SET "keepfile=1.bat"
SET "keepdir=keep me"

FOR /d %%a IN ("%sourcedir%\*") DO IF /i NOT "%%~nxa"=="%keepdir%" RD /S /Q "%%a"
FOR %%a IN ("%sourcedir%\*") DO IF /i NOT "%%~nxa"=="%keepfile%" DEL "%%a"

GOTO :EOF

Berikut ini adalah batch atau command untuk mengcopy semua isi file dan folder ke folder tujuan dengan xcopy

xcopy /e /v .\sourcepath\* D:\destinationdir\

Tinggalkan Balasan

Alamat email Anda tidak akan dipublikasikan.