Last active
February 21, 2020 15:13
-
-
Save Cologler/835e2f385d62d367e8732cced06d76fa to your computer and use it in GitHub Desktop.
a script that create a *.bak file for target file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[Parameter(Position=0, mandatory=$true)] | |
[string] $Path | |
) | |
function RenameBak { | |
param ( | |
[string] $Path | |
) | |
if (Test-Path $Path) { | |
$BakPath = "$Path.bak" | |
RenameBak $BakPath | |
Rename-Item -NewName $BakPath $Path | |
} | |
} | |
function MakeBak { | |
param ( | |
[string] $Path | |
) | |
$BakPath = "$Path.bak" | |
RenameBak $BakPath | |
Copy-Item -Path $Path -Destination $BakPath -Recurse | |
} | |
MakeBak $Path |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[Parameter(Position=0, mandatory=$true)] | |
[string] $Path | |
) | |
$BakPath = "$Path.bak" | |
if (Test-Path $BakPath) { | |
Remove-Item $Path -Recurse | |
Rename-Item -NewName $Path $BakPath | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment