バッチファイル内でPowerShell を使ってファイルをゴミ箱に移動するには、
バッチファイル
powershell.exe -Command "Clear-RecycleBin -Force -ErrorAction SilentlyContinue"
set destination=Y:\temp
for %%f in (%destination%\*.png) do (
echo %%f ToRecycleBin
powershell.exe -Command "Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile('%%f', 'OnlyErrorDialogs', 'SendToRecycleBin')"
)
timeout 11
set target=Y:\temp
for /d %%f in ("%target%\*") do (
echo %%f ToRecycleBin
powershell.exe -Command "Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.FileIO.FileSystem]::DeleteDirectory('%%f', 'OnlyErrorDialogs', 'SendToRecycleBin')"
)
timeout 11
ゴミ箱にファイル フォルダーを移動したりゴミ箱を空にする
ディスカッション
コメント一覧
まだ、コメントがありません