Script to change the product price with meta filed

if there is a way to swap between a meta field that contains our sale price with the price field:

We want to use metafiled ‘sale price’ as a container,

Swap [metafiled ‘sale price’] with [ shopify ‘current price’ ]

then we will put all the products with the same price and compare at price
example:
Item xyz
price = 100 ( displayed )
compare at price = 100 ( displayed )
Metafiled sale price = 50 ( only container and not displayed )

when we have a sale we will swap the price with the sale price
it will be

price = 50( displayed )
compare at price = 100 ( displayed )

Metafiled sale price = 100 ( only container and not displayed )

and when the sale ended we will do the opposite

Hi

You are probably better to manage your sale prices via a CSV upload (e.g Matrixify to schedule sales) or use this app to create rules and schedule sales https://apps.shopify.com/instant-bulk-discount-sales