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

推荐订阅源

Cisco Talos Blog
Cisco Talos Blog
阮一峰的网络日志
阮一峰的网络日志
云风的 BLOG
云风的 BLOG
D
Docker
Vercel News
Vercel News
IT之家
IT之家
Recent Announcements
Recent Announcements
Last Week in AI
Last Week in AI
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
腾讯CDC
Google DeepMind News
Google DeepMind News
I
InfoQ
博客园 - 三生石上(FineUI控件)
Apple Machine Learning Research
Apple Machine Learning Research
The GitHub Blog
The GitHub Blog
博客园 - Franky
The Cloudflare Blog
A
About on SuperTechFans
有赞技术团队
有赞技术团队
Y
Y Combinator Blog
T
Tenable Blog
P
Proofpoint News Feed
Recorded Future
Recorded Future
Security Latest
Security Latest
H
Hackread – Cybersecurity News, Data Breaches, AI and More
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
博客园 - 聂微东
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Google Online Security Blog
Google Online Security Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Simon Willison's Weblog
Simon Willison's Weblog
The Last Watchdog
The Last Watchdog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
N
News and Events Feed by Topic
TaoSecurity Blog
TaoSecurity Blog
U
Unit 42
The Hacker News
The Hacker News
Martin Fowler
Martin Fowler
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
F
Full Disclosure
M
MIT News - Artificial intelligence
人人都是产品经理
人人都是产品经理
Hugging Face - Blog
Hugging Face - Blog
V
V2EX
Project Zero
Project Zero

博客园 - 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' 已被删除。"