侧边栏壁纸
  • 累计撰写 23 篇文章
  • 累计创建 8 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

PowerShell移动目录下所有png文件

付心武士
2024-06-16 / 0 评论 / 0 点赞 / 0 阅读 / 755 字

移动目录下所有png文件到指定目录内

$RootFolder = Read-Host -Prompt "enter the folder you want to move png files from"
$targetFolder = Read-Host -Prompt "enter the folder you want to move png files to"
Write-Output "your files are being moved..."


# Get all PNG files in the source folder
$pngFiles = Get-ChildItem -Path $RootFolder -Filter *.png -Recurse

# Move each PNG file to the target folder
foreach ($pngFile in $pngFiles) {
    $destinationPath = Join-Path -Path $targetFolder -ChildPath $pngFile.Name
    Move-Item -Path $pngFile.FullName -Destination $destinationPath
}

Write-Output "PNG files have been moved successfully."
Write-Output "Total PNG files moved: $($pngFiles.Count)"

0

评论区