-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[minecraft-onedrive] Port screenshots script to PowerShell
- Loading branch information
1 parent
c76fb4b
commit 0e69c75
Showing
2 changed files
with
85 additions
and
40 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
@echo off | ||
Rem Workaround for .ps1 files not being clickable to run | ||
PowerShell -NoExit -Command "Get-Content '%~dpnx0' | Select-Object -Skip 4 | Out-String | Invoke-Expression" | ||
goto :eof | ||
|
||
<# | ||
|
||
# TODO | ||
function Backup-Check { | ||
Write-Host "Have you made a backup?" | ||
$DidBackup = (Read-Host).ToUpper() | ||
|
||
switch ($userResponse) { | ||
"Y" { } | ||
"N" { } | ||
} | ||
} | ||
|
||
#> | ||
|
||
function Exit-Prompt { | ||
Write-Host "Press enter to quit." | ||
$Host.UI.ReadLine() | ||
exit | ||
} | ||
|
||
$ScreenshotsLinkPath = "$env:APPDATA\.minecraft\screenshots" | ||
|
||
If (Test-Path $ScreenshotsLinkPath) { | ||
if ((Get-Item -Path $ScreenshotsLinkPath -Force).LinkType -eq "Junction") { | ||
$LinkTarget = (Get-Item $ScreenshotsLinkPath).Target | ||
|
||
Write-Host "There's already a link at $ScreenshotsLinkPath and it points to $LinkTarget. Do you need to use this script?" | ||
Exit-Prompt | ||
} | ||
|
||
Write-Host "There's already a folder at $ScreenshotsLinkPath, you need to move it to your OneDrive folder before running this script." | ||
Exit-Prompt | ||
} | ||
|
||
$ScreenshotsContainerPath = '' | ||
|
||
function Get-Screenshots-Container-Path { | ||
$EnteredPath = Read-Host -Prompt "Enter the path to the folder within your OneDrive folder where you'll keep your screenshots folder, not including the path to OneDrive itself (eg. Games\Minecraft)" | ||
|
||
If ($EnteredPath -eq '') { | ||
$EnteredPath = Get-Screenshots-Container-Path | ||
} | ||
|
||
return $EnteredPath | ||
} | ||
|
||
$ScreenshotsContainerPath = Get-Screenshots-Container-Path | ||
|
||
$ScreenshotsFullPath = "$env:USERPROFILE\OneDrive\$ScreenshotsContainerPath\screenshots" | ||
|
||
If (-Not (Test-Path $ScreenshotsFullPath)) { | ||
Write-Host "The path $ScreenshotsFullPath doesn't exist, please check." | ||
Exit-Prompt | ||
} | ||
|
||
If (-Not (Test-Path -Path $ScreenshotsFullPath -PathType container)) { | ||
Write-Host "The path $ScreenshotsFullPath isn't a directory." | ||
Exit-Prompt | ||
} | ||
|
||
function make-junction { | ||
Param($link, $target) | ||
|
||
try { | ||
New-Item -Path $link -ItemType Junction -Value $target | Out-Null | ||
} | ||
|
||
catch { | ||
Write-Host "Couldn't create a link, there was an error:" | ||
Write-Host $_ | ||
Exit-Prompt | ||
} | ||
} | ||
|
||
make-junction $ScreenshotsLinkPath $ScreenshotsFullPath | ||
|
||
Write-Host "Done." | ||
|
||
Exit-Prompt |