The efficient operation of power-electronic-based systems heavily relies on the reliability and longevity of battery-powered systems. An accurate prediction of the remaining useful life (RUL) of batteries is essential for their effective maintenance, reliability, and safety. However, traditional RUL prediction methods and deep learning-based approaches face challenges in managing battery degradation processes, such as achieving robust prediction performance, to ensure scalability and computational efficiency. There is a need to develop adaptable models that can generalize across different battery types that operate in diverse operational environments. To solve these issues, this research work proposes a TransRUL model to enhance battery RUL prediction. The proposed model incorporates advanced approaches of a time series transformer using a dual encoder with integration positional encoding and multi-head attention. This research utilized data collected by the Centre for Advanced Life Cycle Engineering (CALCE) on CS_2-type lithium-ion batteries that spanned four groups that used a sliding window technique to generate features and labels. The experimental results demonstrate that TransRUL obtained superior performance as compared with other methods in terms of the following evaluation metrics: mean absolute error (MAE), root-mean-squared error (RMSE), and R2 values. The efficient computational power of the TransRUL model will facilitate the real-time prediction of the RUL, which is vital for power-electronic-based appliances. This research highlights the potential of the TransRUL model, which significantly enhances the accuracy of battery RUL prediction and additionally improves the management and control of battery-based systems.