-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task.ps1
78 lines (61 loc) · 2.07 KB
/
Task.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
while($true)
{
$ptde = Get-Process -Name "DARKSOULS" -ErrorAction SilentlyContinue
$dsr = Get-Process -Name "DarkSoulsRemastered" -ErrorAction SilentlyContinue
$ds2 = Get-Process -Name "DarkSoulsII" -ErrorAction SilentlyContinue
$sotfs = Get-Process -Name "DarkSoulsII" -ErrorAction SilentlyContinue
$ds3 = Get-Process -Name "DarkSoulsIII" -ErrorAction SilentlyContinue
$sek = Get-Process -Name "sekiro" -ErrorAction SilentlyContinue
$er = Get-Process -Name "eldenring" -ErrorAction SilentlyContinue
$bb = Get-Process -Name "Bloodborne" -ErrorAction SilentlyContinue
function Get-LastTouched
{
param([String]$Path,[String]$Extension)
Get-ChildItem -Path $Path -File -Depth 4 -Include $Extension | Sort-Object -Descending -Property LastWriteTime | Select-Object -First 1
}
function New-Backup
{
param([String]$Path,[String]$Extension)
$file = Get-LastTouched -Path $path -Extension $Extension
if($file)
{
$time = Get-Date -Format "yyyy-MM-dd_HH-mm"
$new_name = ($file.FullName).Replace($Extension,$Extension.Replace(".","_")) + "_" + $time + ".bak"
Copy-Item -Path $file.FullName -Destination $new_name
}
}
if($ptde)
{
New-Backup -Path "$HOME\Documents\NBGI\DarkSouls\" -Extension "*.sl2"
}
if($dsr)
{
New-Backup -Path "$HOME\Documents\NBGI\DARK SOULS REMASTERED\" -Extension "*.sl2"
}
if($ds2)
{
New-Backup -Path "$env:APPDATA\DarkSoulsII\" -Extension "*.sl2"
}
if($sotfs)
{
New-Backup -Path "$env:APPDATA\DarkSoulsII\" -Extension "*.sl2"
}
if($ds3)
{
New-Backup -Path "$env:APPDATA\DarkSoulsIII\" -Extension "*.sl2"
}
if($sek)
{
New-Backup -Path "$env:APPDATA\Sekiro\" -Extension "*.sl2"
}
if($er)
{
New-Backup -Path "$env:APPDATA\EldenRing\" -Extension "*.sl2"
New-Backup -Path "$env:APPDATA\EldenRing\" -Extension "*.co2"
}
if($bb)
{
New-Backup -Path "$env:APPDATA\Bloodborne\" -Extension "*.sl2"
}
Start-Sleep -Seconds 600
}