Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Requires: PSFTP Module (https://gallery.technet.microsoft.com/scriptcenter/PowerShell-FTP-Client-db6fe0cb)
- ff7save (http://www.zophar.net/utilities/genutil/ff7-savegame-converter.html)
- ## Sync-FF7Save.ps1
- --------------------------------------------------------------------------------------------------------------------------------------
- ################
- # Sync-FF7Save #
- ################
- # I tried doing this without this module and it was hacky, ugly, and stupid. Thanks, guy who wrote this module.
- Import-Module PSFTP
- # General Script Variables
- $LOCALSAVE="D:\Libraries\<username>\My Documents\Square Enix\FINAL FANTASY VII Steam\user_1234567\save00.ff7"
- $LOCALBACKUP="D:\Libraries\<username>\My Documents\Square Enix\FINAL FANTASY VII Steam\user_1234567\save00.ff7.backup"
- $WORKINGLOCALSAVE="D:\Libraries\<username>\My Documents\Square Enix\FF7 Save Sync\save00.ff7"
- $ANDROIDSAVE="/mnt/external_sd/MEMCARDS/ff7_pc.mcd"
- $ANDROIDBACKUP="/mnt/external_sd/MEMCARDS/ff7_pc.mcd.backup"
- $WORKINGANDROIDSAVE="D:\Libraries\<username>\My Documents\Square Enix\FF7 Save Sync\ff7_pc.mcd"
- $WORKINGANDROIDBACKUP="D:\Libraries\<username>\My Documents\Square Enix\FF7 Save Sync\ff7_pc.mcd.backup"
- $WORKINGDIR="D:\Libraries\<username>\My Documents\Square Enix\FF7 Save Sync\"
- #FTP Support Variables
- $ANDROIDFTP="ftp://gpdxd:31337"
- $ANDROIDDIR="/mnt/external_sd/MEMCARDS/"
- $USERNAME = "<username>"
- $PASSWORD = "android" | ConvertTo-SecureString -asPlainText -Force
- $CREDENTIAL = New-Object System.Management.Automation.PSCredential($USERNAME,$PASSWORD)
- # Set Save Sync Directory
- Set-Location $WORKINGDIR
- # Delete working copies of saves if they exist
- If (Test-Path $WORKINGLOCALSAVE){Remove-Item $WORKINGLOCALSAVE}
- If (Test-Path $WORKINGANDROIDSAVE){Remove-Item $WORKINGANDROIDSAVE}
- If (Test-Path $WORKINGANDROIDBACKUP){Remove-Item $WORKINGANDROIDBACKUP}
- # Copy Local Save to Save Sync Directory
- Copy-Item $LOCALSAVE $WORKINGLOCALSAVE
- #Initiate Connection to Android Device
- Set-FTPConnection -Credentials $CREDENTIAL -Server $ANDROIDFTP -Session AndroidFF7SyncSession -UsePassive
- $FTPSession = Get-FTPConnection -Session AndroidFF7SyncSession
- # Download Remote Save to Save Sync Directory
- Get-FTPItem -Session $FTPSession -Path $ANDROIDSAVE -LocalPath $WORKINGANDROIDSAVE
- Copy-Item $WORKINGANDROIDSAVE $WORKINGANDROIDBACKUP
- # Check Timestamp of Remote Save vs. Local Save
- $RemoteTimestamp = [datetime](Get-FTPChildItem -Session $FTPSession -Path /mnt/external_sd/MEMCARDS/ff7_pc.mcd).ModifiedDate # Get timestamp of Remote Save from Save Sync Directory
- $LocalTimestamp = [datetime](Get-ItemProperty -Path $WORKINGLOCALSAVE -Name LastWriteTime).lastwritetime # Get timestamp from Local Save from Save Sync Directory
- # If Remote Save is newer, back up local save and replace
- If ($RemoteTimestamp -gt $LocalTimestamp) {
- If (Test-Path $LOCALBACKUP){Remove-Item $LOCALBACKUP} # Remove existing backup if it exists
- Copy-Item $WORKINGLOCALSAVE $LOCALBACKUP ## Make backup copy of local save00.ff7
- CMD /C "remote.cmd" ## Convert .MCD format FF7 save to .FF7 save format save
- Remove-Item $LOCALSAVE ## Replace save00.ff7
- Copy-Item $WORKINGLOCALSAVE $LOCALSAVE
- Write-Host "Remote save was newer. Local save has been backed up and replaced."
- Write-Host "Launching Black_Chocobo to remind you to open and save the file until this step has been removed."
- & "D:\Program Files (x86)\Black_Chocobo\Black_Chocobo.exe"
- }
- # If Local save is newer, back up remote save and replace
- If ($LocalTimestamp -gt $RemoteTimestamp) {
- # Re-upload downloaded ff7_pc.mcd to ff7_pc.mcd backup
- Add-FTPItem -Session $FTPSession -Path $ANDROIDDIR -LocalPath $WORKINGANDROIDBACKUP -Overwrite
- CMD /C "local.cmd" # Convert .ff7 format FF7 save to .MCD save format save
- # Replace ff7_pc.mcd
- Add-FTPItem -Session $FTPSession -Path $ANDROIDDIR -LocalPath $WORKINGANDROIDSAVE -Overwrite
- Write-Host "Local save was newer. Remote save has been backed up and replaced."
- }
- # remote.cmd
- --------------------------------------------------------------------------------------------------------------------------------------
- ff7save < remote.txt
- # remote.txt
- --------------------------------------------------------------------------------------------------------------------------------------
- 1
- ff7_pc.mcd
- 1
- 4
- save00.ff7
- 1
- 1
- # local.cmd
- --------------------------------------------------------------------------------------------------------------------------------------
- ff7save < local.txt
- # local.txt
- --------------------------------------------------------------------------------------------------------------------------------------
- 4
- save00.ff7
- 1
- 1
- ff7_pc.mcd
- 1
- 1
- 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement