Advertisement
Guest User

Untitled

a guest
Jul 4th, 2016
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.66 KB | None | 0 0
  1. Requires: PSFTP Module (https://gallery.technet.microsoft.com/scriptcenter/PowerShell-FTP-Client-db6fe0cb)
  2. ff7save (http://www.zophar.net/utilities/genutil/ff7-savegame-converter.html)
  3.  
  4. ## Sync-FF7Save.ps1
  5. --------------------------------------------------------------------------------------------------------------------------------------
  6. ################
  7. # Sync-FF7Save #
  8. ################
  9. # I tried doing this without this module and it was hacky, ugly, and stupid. Thanks, guy who wrote this module.
  10. Import-Module PSFTP
  11.  
  12. # General Script Variables
  13. $LOCALSAVE="D:\Libraries\<username>\My Documents\Square Enix\FINAL FANTASY VII Steam\user_1234567\save00.ff7"
  14. $LOCALBACKUP="D:\Libraries\<username>\My Documents\Square Enix\FINAL FANTASY VII Steam\user_1234567\save00.ff7.backup"
  15. $WORKINGLOCALSAVE="D:\Libraries\<username>\My Documents\Square Enix\FF7 Save Sync\save00.ff7"
  16. $ANDROIDSAVE="/mnt/external_sd/MEMCARDS/ff7_pc.mcd"
  17. $ANDROIDBACKUP="/mnt/external_sd/MEMCARDS/ff7_pc.mcd.backup"
  18. $WORKINGANDROIDSAVE="D:\Libraries\<username>\My Documents\Square Enix\FF7 Save Sync\ff7_pc.mcd"
  19. $WORKINGANDROIDBACKUP="D:\Libraries\<username>\My Documents\Square Enix\FF7 Save Sync\ff7_pc.mcd.backup"
  20. $WORKINGDIR="D:\Libraries\<username>\My Documents\Square Enix\FF7 Save Sync\"
  21.  
  22. #FTP Support Variables
  23. $ANDROIDFTP="ftp://gpdxd:31337"
  24. $ANDROIDDIR="/mnt/external_sd/MEMCARDS/"
  25. $USERNAME = "<username>"
  26. $PASSWORD = "android" | ConvertTo-SecureString -asPlainText -Force
  27. $CREDENTIAL = New-Object System.Management.Automation.PSCredential($USERNAME,$PASSWORD)
  28.  
  29. # Set Save Sync Directory
  30. Set-Location $WORKINGDIR
  31.  
  32. # Delete working copies of saves if they exist
  33. If (Test-Path $WORKINGLOCALSAVE){Remove-Item $WORKINGLOCALSAVE}
  34. If (Test-Path $WORKINGANDROIDSAVE){Remove-Item $WORKINGANDROIDSAVE}
  35. If (Test-Path $WORKINGANDROIDBACKUP){Remove-Item $WORKINGANDROIDBACKUP}
  36.  
  37. # Copy Local Save to Save Sync Directory
  38. Copy-Item $LOCALSAVE $WORKINGLOCALSAVE
  39.  
  40. #Initiate Connection to Android Device
  41. Set-FTPConnection -Credentials $CREDENTIAL -Server $ANDROIDFTP -Session AndroidFF7SyncSession -UsePassive
  42. $FTPSession = Get-FTPConnection -Session AndroidFF7SyncSession
  43.  
  44. # Download Remote Save to Save Sync Directory
  45. Get-FTPItem -Session $FTPSession -Path $ANDROIDSAVE -LocalPath $WORKINGANDROIDSAVE
  46. Copy-Item $WORKINGANDROIDSAVE $WORKINGANDROIDBACKUP
  47.  
  48. # Check Timestamp of Remote Save vs. Local Save
  49. $RemoteTimestamp = [datetime](Get-FTPChildItem -Session $FTPSession -Path /mnt/external_sd/MEMCARDS/ff7_pc.mcd).ModifiedDate # Get timestamp of Remote Save from Save Sync Directory
  50. $LocalTimestamp = [datetime](Get-ItemProperty -Path $WORKINGLOCALSAVE -Name LastWriteTime).lastwritetime # Get timestamp from Local Save from Save Sync Directory
  51.  
  52. # If Remote Save is newer, back up local save and replace
  53. If ($RemoteTimestamp -gt $LocalTimestamp) {
  54. If (Test-Path $LOCALBACKUP){Remove-Item $LOCALBACKUP} # Remove existing backup if it exists
  55. Copy-Item $WORKINGLOCALSAVE $LOCALBACKUP ## Make backup copy of local save00.ff7
  56. CMD /C "remote.cmd" ## Convert .MCD format FF7 save to .FF7 save format save
  57. Remove-Item $LOCALSAVE ## Replace save00.ff7
  58. Copy-Item $WORKINGLOCALSAVE $LOCALSAVE
  59. Write-Host "Remote save was newer. Local save has been backed up and replaced."
  60. Write-Host "Launching Black_Chocobo to remind you to open and save the file until this step has been removed."
  61. & "D:\Program Files (x86)\Black_Chocobo\Black_Chocobo.exe"
  62. }
  63.  
  64. # If Local save is newer, back up remote save and replace
  65. If ($LocalTimestamp -gt $RemoteTimestamp) {
  66. # Re-upload downloaded ff7_pc.mcd to ff7_pc.mcd backup
  67. Add-FTPItem -Session $FTPSession -Path $ANDROIDDIR -LocalPath $WORKINGANDROIDBACKUP -Overwrite
  68. CMD /C "local.cmd" # Convert .ff7 format FF7 save to .MCD save format save
  69. # Replace ff7_pc.mcd
  70. Add-FTPItem -Session $FTPSession -Path $ANDROIDDIR -LocalPath $WORKINGANDROIDSAVE -Overwrite
  71. Write-Host "Local save was newer. Remote save has been backed up and replaced."
  72. }
  73.  
  74. # remote.cmd
  75. --------------------------------------------------------------------------------------------------------------------------------------
  76. ff7save < remote.txt
  77.  
  78. # remote.txt
  79. --------------------------------------------------------------------------------------------------------------------------------------
  80. 1
  81. ff7_pc.mcd
  82. 1
  83. 4
  84. save00.ff7
  85. 1
  86. 1
  87.  
  88. # local.cmd
  89. --------------------------------------------------------------------------------------------------------------------------------------
  90. ff7save < local.txt
  91.  
  92. # local.txt
  93. --------------------------------------------------------------------------------------------------------------------------------------
  94. 4
  95. save00.ff7
  96. 1
  97. 1
  98. ff7_pc.mcd
  99. 1
  100. 1
  101. 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement