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

推荐订阅源

Martin Fowler
Martin Fowler
Y
Y Combinator Blog
M
MIT News - Artificial intelligence
The Cloudflare Blog
WordPress大学
WordPress大学
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 司徒正美
小众软件
小众软件
Blog — PlanetScale
Blog — PlanetScale
雷峰网
雷峰网
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
J
Java Code Geeks
云风的 BLOG
云风的 BLOG
C
Check Point Blog
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
V
V2EX
F
Fortinet All Blogs
B
Blog
大猫的无限游戏
大猫的无限游戏
N
Netflix TechBlog - Medium
B
Blog RSS Feed
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

博客园 - e3tB8Wz7

一行代码解决 Chrome 对 HTTP 站点 Office 文件的下载拦截 鼠标连选问题排查与解决 Vue 3 + Vite 生产构建下自定义弹窗组件大面积失效:根因排查与修复实录 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' 已被删除。"