This is doable and this is how I would do it.
Make your days long. Start early and give yourself a full day. When you travel between the two cities, take an early morning train. This way, you'll have the afternoon for sightseeing.
Stay close to the central parts of town. This will save on commuting time to get to the main sites.
This next one will get some people's feathers all ruffled. In Edinburgh, consider getting a multi day Hop On Hop Off Bus Ticket. There are four lines that go to practically everything. It will save time trying to find public transit. You can stay on for one full loop for the guided commentary and then get off to see the sites. Some of the lines overlap so with good planning you can maximize your time.
I have never taken the Hop On Hop Off bus in London but it might be something to look into for the same reason. Although there, the tube makes life easy for the tourist as it can get you close to most sites.
Also try to sightsee in the same area. Don't go from one end of town and back numerous times. Use the Rick Steves Guidebooks for each city as he does give tips on how to save time on lines in both cities.
For an eight day trip, you can rest when you get home.