JavaScript: Create title from attributes

This script changes the title of all selected listings based on the given text and attributes.
Feel free to modify and improve it to fit your needs.

Disclaimer:

  • You might want to test this script with one single listing first.
  • There’s no undo function.
  • The script ignores the 80 characters limit for listing titles.

More about GarageSale’s javascript feature: Running Scripts

// Create title from attributes
function run() {

	for (const listing of selectedListings) {

	var thisBrand = "";
	var thisSize = "";
	var thisColour = "";

		if (!listing.attributes["Brand"]) {
			consoleLog("NO BRAND");
		} else {
			thisBrand = listing.attributes["Brand"] + " ";
		}

		if (!listing.attributes["Size"]) {
			consoleLog("NO SIZE");
		} else {
			thisSize = "Size" + " " + listing.attributes["Size"] + " ";
		}

		if (!listing.attributes["Colour"]) {
			consoleLog("NO COLOUR");
		} else {
			thisColour = listing.attributes["Colour"] + " ";
		}

		listing.title = "Text" + " " + thisBrand + thisSize + thisColour + "Text";

	}
}

There may also be differences in the way some attributes are spelled, such as “Color” in the US

1 Like