param([String]$fileName)
$Target = "C:\Users\pb\Desktop\destination"
if (Test-Path $fileName)
{
Copy-Item $fileName $Target
} Else
{
"File does not exist"
}
答案 0 :(得分:0)
你可以这样做:
param([String]$fileName)
if (Test-Path $fileName)
{
$file = [io.path]::GetFileNameWithoutExtension($fileName)
$ext = [io.path]::GetExtension($fileName)
$Target = "C:\Users\pb\Desktop\destination" + $file + $(get-date -f yyyy-MM-dd) + $ext
Move-Item $fileName $Target
}
Else {
Write-Host "File does not exist!"
}