For example, if a product price is 29.99 and the compare at price is 39.99, I want to apply discount at the compare at price and not the product price, is that possible by an app or some code? Because I have a lot of products and I don’t want to change them one by one!
Discounts are based on the set product price. You would have to create an app to even being to try and generate discounts based on that.
Then dont use a spreadsheet https://help.shopify.com/en/manual/products/import-export/import-products
Or the admin bulk editor https://help.shopify.com/en/manual/shopify-admin/productivity-tools/bulk-editing-products