Day 1: Trains from Barcelona, Spain to Nice, France. 12 hours.
Day 2: Trains from Nice, France to Villach, Austria. 14 hours.
Day 3: Train from Villach, Austria to Ljubljana, Slovenia (destination). 1.5 hours.