Let me make an off the wall suggestion.
Do a few days in Vienna, then go on to Budapest for a few days, then fly from Budapest to Podgorica in Montenegro its about an hour flight and it arrives at 7:30 pm so spend the night in Podgorica. The first night is the only thing about this plan I don't really like. Hire a guide with a car and drive to Perast for a night then on to Dubrovnik. I can maybe recommend a guide.
July 9 Arrive Vienna
10 Vienna
11 Vienna
12 early train to Budapest
13 Budapest
14 Budapest
15 Budapest
16 early evening flight to Podgorica (Wizzair, non stop about $100). Has to be on the 16th as the flight only goes on Sunday and Wednesday
17 Podgorica to Budva to Perast (skip the town of Kotor, Dubrovnik is better)
18 late drive from Perast to Dubrovnik. So great stops along the way. You need a guide to get your money's worth.
19 Dubrovnik; As great as Dubrovnik is, its a tourist trap. Worth seeing and experiencing for a night or two, then run.
20 Dubrovnik to Vienna (Austrian Air, non-stop, about $225)
21 Vienna
22 Vienna home
Skip Vienna and run the trip in the other direction and you have a trip we took a few years ago. Montenegro was so outstanding we are heading back for a week in the fall.