macbook shuts down immediately after startup My retina MacBook Pro, running 10.12.6, has an annoying habit.

If I close the lid on 50% battery, the next time I open it, it wakes, I log in, and then a few seconds later the screen goes black and it shuts down.  

Pressing the power button enough brings up the 'flat battery' logo.

My assumption was that the battery is reporting 50%, but is in fact flat.

If I plug it in to charge, it then resumes where it left off, but if I unplug the power, it will continue to work for another couple of hours.  So it's not actually drained, it just temporarily thinks it is.

What can I do, other than replace the battery?
To verify your problem I need you to post the Battery status in detail.

Click About this Mack (top left) > Syst report > Power 

then copy the battery information in your original post.

To preserve some power consumption, open syst pref > Energy and disable the Power nap in Battery mode.

To verify is some process is keeping your Mac awake (dark mode) and consuming power open Terminal and paste following 

pmset g  and post the info here

also run pmset -g assertions and post it here

Under normal (perfect) condition the battery should last 1,000 cycles, but that is not always the case, so your are getting close with your 700 cycles