惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
SecWiki News
SecWiki News
酷 壳 – CoolShell
酷 壳 – CoolShell
爱范儿
爱范儿
量子位
M
MIT News - Artificial intelligence
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
TaoSecurity Blog
TaoSecurity Blog
博客园 - 【当耐特】
H
Heimdal Security Blog
腾讯CDC
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
博客园 - 司徒正美
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Cybersecurity and Infrastructure Security Agency CISA
S
SegmentFault 最新的问题
大猫的无限游戏
大猫的无限游戏
Application and Cybersecurity Blog
Application and Cybersecurity Blog
F
Full Disclosure
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
T
Threatpost
月光博客
月光博客
A
Arctic Wolf
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
T
Troy Hunt's Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Cloudflare Blog
D
DataBreaches.Net
O
OpenAI News
L
LINUX DO - 最新话题
宝玉的分享
宝玉的分享
小众软件
小众软件
V
Vulnerabilities – Threatpost
A
About on SuperTechFans
人人都是产品经理
人人都是产品经理
T
The Exploit Database - CXSecurity.com
Martin Fowler
Martin Fowler
美团技术团队
P
Privacy International News Feed

博客园 - e3tB8Wz7

Windows PowerShell 查看特定网卡的详细信息 阿里云 CentOS 7 yum镜像(Centos-7.repo) 一行命令查看docker所有网络 + 子网 nginx配置文件生产环境优化 Microsoft Office 安装与激活 Microsoft Edge隐藏边栏快捷键 微信小程序hideLoading隐藏showToast提示的问题 前端开发解决方案 pl/sql developer设置oracle环境变量 postman-app下载官方历史版本 logback日志格式 springboot alibaba druid数据库连接池配置,输出可执行sql 统计accesslog日志中的慢接口,排序后取前几条 将多个文件的内容附加到一个文件中 统计accesslog日志中每个url的请求次数,排序后取前几条 如何在反向代理后面部署spring服务? Shell:用sed命令删除特定行 Git for Windows 国内下载站 oracle查询日期属于一年的第几周,日期所在周的周一是哪一天
powershell上移文件夹下的所有文件
e3tB8Wz7 · 2025-10-15 · via 博客园 - e3tB8Wz7

将某个文件夹(例如 .\OldFolder)下的所有文件和子文件夹“上移”到其父目录中,然后 删除这个空的 OldFolder

# 提示用户输入要上移的文件夹路径
$folderPath = Read-Host "请输入要上移内容的文件夹完整路径(例如:C:\Parent\OldFolder)"

# 去除首尾空格
$folderPath = $folderPath.Trim()

# 验证路径是否存在
if (-not (Test-Path -Path $folderPath -PathType Container)) {
    Write-Error "错误:路径不存在或不是一个文件夹:$folderPath"
    exit 1
}

# 获取父目录
$parentDir = Split-Path -Parent $folderPath
$folderName = Split-Path -Leaf $folderPath

Write-Host "即将把文件夹 '$folderName' 中的所有内容移动到父目录:`n  $parentDir`n"

# 列出将要移动的项目(可选预览)
$items = Get-ChildItem -Path $folderPath -Force
if ($items) {
    Write-Host "将移动以下 $($items.Count) 个项目:"
    $items | ForEach-Object { Write-Host "  - $($_.Name)" }
} else {
    Write-Host "文件夹为空,将直接删除。"
}

# 确认操作
$confirm = Read-Host "是否继续?(Y/N)"
if ($confirm -notmatch '^[Yy]$') {
    Write-Host "操作已取消。"
    exit 0
}

# 执行移动
if ($items) {
    foreach ($item in $items) {
        $destPath = Join-Path -Path $parentDir -ChildPath $item.Name

        if (Test-Path -Path $destPath) {
            Write-Warning "目标已存在,跳过:$($item.Name)"
            # 如需覆盖,可取消下面两行注释
            # Remove-Item -Path $destPath -Recurse -Force
            # Move-Item -Path $item.FullName -Destination $parentDir -Force
        } else {
            Move-Item -Path $item.FullName -Destination $parentDir
            Write-Host "已移动:$($item.Name)"
        }
    }
}

# 删除原文件夹
Remove-Item -Path $folderPath -Recurse -Force
Write-Host "`n✅ 操作完成!文件夹 '$folderName' 已被删除。"