灭霸指令

mqx 2026-08-18 08:29 1

简介:随机删除当前目录一半的文件(移动到回收站,不会真的删除,哈哈哈)


windows:


$f=Get-ChildItem . -File -Recurse; $victims=$f | Get-Random -Count ([math]::Floor($f.Count/2)); $shell=New-Object -ComObject Shell.Application; Write-Host "🫰 灭霸响指:共 $($f.Count) 个文件,随机消灭 $($victims.Count) 个"; $i=0; foreach($x in $victims){$i++; Write-Host "[$i/$($victims.Count)] 💨 $($x.FullName)"; $shell.Namespace(10).MoveHere($x.FullName); Start-Sleep -Milliseconds 100}; Write-Host "☠️ 宇宙恢复了平衡。"

linux:


files=(); while IFS= read -r -d '' f; do files+=("$f"); done < <(find . -type f -print0); total=${#files[@]}; count=$((total/2)); printf '%s\0' "${files[@]}" | shuf -z -n "$count" | { i=0; while IFS= read -r -d '' f; do i=$((i+1)); echo "[$i/$count] 💨 $f"; gio trash "$f"; sleep 0.1; done; }; echo "🫰 宇宙恢复了平衡。"

mac:


files=(); while IFS= read -r -d '' f; do files+=("$f"); done < <(find . -type f -print0); total=${#files[@]}; count=$((total/2)); trash="$HOME/.Trash/Thanos-$(date +%Y%m%d-%H%M%S)"; mkdir -p "$trash"; printf '%s\0' "${files[@]}" | perl -0MList::Util=shuffle -e '@x=shuffle(<>); print @x[0..$ENV{N}-1]' N="$count" | { i=0; while IFS= read -r -d '' f; do i=$((i+1)); echo "[$i/$count] 💨 $f"; mv "$f" "$trash/"; sleep 0.1; done; }; echo "🫰 宇宙恢复了平衡。文件位于废纸篓中的 $(basename "$trash")"
最新回复 (2)
  • maolon 08-18 08:43
    1
    哈哈哈🤣,拿来测试了一下从网页直接 run 命令的功能能不能拦住
  • mqx 楼主 08-18 08:57
    2
    @maolon #1 哈哈哈
* 帖子来源V2EX
返回