Skip to content

Instantly share code, notes, and snippets.

@toagit
Created February 9, 2017 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toagit/71b85c29015447ea1a4244b4e5462057 to your computer and use it in GitHub Desktop.
Save toagit/71b85c29015447ea1a4244b4e5462057 to your computer and use it in GitHub Desktop.
リストファイルに存在しないフォルダを削除する
@echo off
pushd %0\..
setlocal enabledelayedexpansion
set "TARGET_FOLDER=D:\xxxx"
for /f "tokens=*" %%a in ('dir %TARGET_FOLDER% /b /a:d') do (
set SHOULD_DEL=true
for /f "tokens=1* skip=1" %%i in (include.list) do (
if "%%a"=="%%j" (
echo [DEBUG] -- バックアップ対象:%%j
set SHOULD_DEL=false
)
)
if !SHOULD_DEL!==true (
echo rd "%TARGET_FOLDER%\%%a" /q/s
echo [INFO] -- %TARGET_FOLDER%\%%aを削除しました。
)
)
pause
from to
from1 to1
from2 to2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment