I enjoy learning new ways to do things semi-automatically so if I have something I do frequently, I try to automate it for one click. I am however pretty inexperienced at it. I much prefer to be shown Why the script works rather than just having it written for me.
My current project is this:
I am trying to find a simple way to with one click update a zip directory. specifically a mod for farming simulator 19 I currently download as a zip from github, which is updated every couple days.
the steps I think I need to follow are to: 1. Obtain new release (think i have this one working) 2. zip new release (kindof working but not quite right) 3. overwrite existing zip with new one (if i can fix my current method of doing step2 it does this automatically) 4.(optional) launch game after all files are finished saving
I have been working on this for a couple days between digging through other peoples questions, and doing trial and error of bits of code.
1: I have found that I can download it automatically by way of cmd.exe using the following:
git clone https://github.com/Courseplay/courseplay.git C:\Users\*****\Documents\courseplay
From what I have read I am uncertain if this is what I want though. is the result of this command the same thing as I would get from 'download .zip'
2, 3: I learned that I can then zip, and overwrite the existing file by way of powershell with:
Compress-Archive -Force -Path "C:\Users\*****\Documents\courseplay" -DestinationPath "C:\Users\*****\Documents\My Games\FarmingSimulator2019\mods\courseplay.zip"
However this isn't working as I hoped/expected as it is adding the folder to a zip rather than just zipping its contents...
to clarify i am looking for:
Courseplay.zip --some files
I am getting
Courseplay.zip --Courseplay ----some files
Furthermore, I have not been able to combine them into one item. I cant use the git command from powershell, and I cant seem to create or interact with files in a zipped folder from cmd. I tried using powershell to pass to cmd a couple of ways I saw in Running CMD command in PowerShell
cmd.exe "git clone https://github.com/Courseplay/courseplay.git c:\Users\*****\Documents\courseplay"
Which outputs
'ourseplay' is not recognized as an internal or external command, operable program or batch file.
cmd.exe /c "git clone https://github.com/Courseplay/courseplay.git c:\Users\*****\Documents\courseplay"
Which outputs
'git' is not recognized as an internal or external command, operable program or batch file.
"git clone https://github.com/Courseplay/courseplay.git c:\Users\*****\Documents\courseplay
" | cmd.exe
Which outputs
Microsoft Windows [Version 10.0.17134.706]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Users\*****\Documents>git clone https://github.com/Courseplay/courseplay.git c:\Users\*****\Documents\courseplay
Cloning into 'c:\Users\*****\Documents\courseplay'...
fatal: unable to access 'https://github.com/Courseplay/courseplay.git/': Could not resolve host: github.com
So my primary issues are: How to zip the contents of a folder where my current method is creating a zip with the original folder as a subfolder
and
I currently must use two different tools to do this. Is there a way i can script it to do all of the above with one doubleclick.
I have not really looked into launching the game as part of the script yet, as i am still struggling with getting the rest of it working and it was an afterthought. I do know in cmd
start steam://rungameid/787860
will launch it.
I would be fine with cmd, powershell, or some other form of scripting that is able to accomplish all of the above.
Additionally is something needed to tell it to wait between steps. (does it by default wait for completion of the download from git clone before it moves to the next step, or does it have to be told to wait while the download finishes)