Dunhuang Railway Station is about 12km away from center of the city .It is well equipped new station with green buses meeting every train to shuttle passengers into town. Just come out the front of the train station and they will usher you into the next bus and for 3 yuan drop you opposite the Silk Road Hotel in town on the edge of the market. There is also a ticket agent in town, near the mosque which sells tickets for most trains. You can always get the bus back to the railway station to buy your ticket if heading to the Caves as you can walk to Caves entrance from the station
Jiayuguan, Lanzhou and Xi'an have direct trains to Dunhuang Railway Station:
Jiayuguan-Dunhuang Station: More than 400 kilometers away, the whole journey is about 5 hours, the fare: about 55/100 yuan (hard seat / hard sleeper);
Lanzhou-Dunhuang Station: There are two trains that are all in the evening, the whole journey is about 14 hours. The fare is about 150/250 yuan (hard seat/hard sleeper). These two trains are often full during the peak period of travel, sometimes with hard seat tickets. Can't buy it;
Xi'an-Dunhuang Station: The whole journey is about 22 hours. The fare is about 200/360 yuan (hard seat/hard sleeper).