powershell PowerShell:文件存档
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell PowerShell:文件存档相关的知识,希望对你有一定的参考价值。
# Archive Function:
function ArchiveFile {
param([string]$filename)
$FolderExist = "$PSScriptRoot\Archive"
if (!(Test-Path $FolderExist -PathType Container)) {
mkdir "$PSScriptRoot\Archive"
}
if (Test-Path $filename) {
$file = [io.path]::GetFileNameWithoutExtension($filename)
$ext = [io.path]::GetExtension($filename)
$target = "$PSScriptRoot\Archive\" + $file + $(get-date -f yyyy-mm-dd) + $ext
Move-Item $filename $target
}
else {
write-output "File doesn't exist"
}
}
$FileLocation = "Location\to\file\here"
ArchiveFile($FileLocation)
以上是关于powershell PowerShell:文件存档的主要内容,如果未能解决你的问题,请参考以下文章