Rewriting the title

Hey everyone… so, ive been in contact with ebay, and the recommend adjusting my titles ( 2000+ ) different items…

With my old software, i used to be able to rewrite the title using the placeholders - i know you can do this on GS in the description… ( e.g - [[foreach attr item.previewSpecifics attLoop]][[if attr.name==“Size”]][[attr.value]][[endif]][[endforeach attLoop]] ) can this been done in the title at all??

Im hoping so

All the best

There is no way yet to use placeholders in the title field but maybe you can adjust the existing “Change listing title attributes” Apple Script to fit your needs? (Select “Show AppleScript Examples” from GarageSale 's Help menu.)

If this won’t work for you, maybe you find the “Bulk Find and Replace” feature useful?:
https://manual.iwascoding.com/gs8/en/Listings_Section-Bulk_Editing.html
You can set its Search Scope to “Title”.

Regards, Kristian

Hello Kristian, thank sfor the reply. okay i will take a look, hopefully it will work…

thanks

Wow that looks terrifying - am i reading this right…

If i run that… it will look for a listing with the specific “Material” e.g ( denim ) that will then put the word denim in the title?

Screenshot 2022-06-16 at 18.43.05

Just had a thought. please see attached… the custom title works perfectly for the description… would htere be anyway of telling GS to use that as the main title?

All the best

Based on the manual, it definitely seems like you can read/write attribute values you’re looking for using JavaScript, concatenate that into a new string, and write the result to the title.

https://manual.iwascoding.com/gs8/en/Custom_JavaScript_Actions-eBay_Listing_JavaScript_properties.html

Hiya!!! yeah funnily enough i was looking at this page when you sent the message…

It would be ideal to run a script in GS itself, as i would like the specifics slightly different depending on the type…

Im trying to figure out java on google… as by the look of that doc, i could use the " read/write The attributes (item specifics). " to the " read/write The listing’s title. "

so hopefully something simple like - {brand} in {size} {colour} {style}

Dont suppose you have any pointers at all do you?as that would be an ideal fix for me to get on with…

i have this to write the descriptions where i can rewrite selected items description…

function run() {
consoleLog("selectedListings: " + selectedListings.length);
for (const listing of selectedListings) {
// consoleLog(listing.itemDescription);
listing.itemDescription = “test”;
// consoleLog(listing.itemDescription);
}
}

All the best

I adjusted that to

function run() {
consoleLog("selectedListings: " + selectedListings.length);
for (const listing of selectedListings) {
// consoleLog(listing.title);
listing.title = “change title”;
// consoleLog(listing.title);
}
}

Which changes the title great! but was hoping to use it like this

function run() {
consoleLog("selectedListings: " + selectedListings.length);
for (const listing of selectedListings) {
// consoleLog(listing.title);
listing.title = “[[foreach attr item.previewSpecifics attLoop]][[if attr.name==“Brand”]][[attr.value]][[endif]][[endforeach attLoop]]”;
// consoleLog(listing.title);
}
}

But that doesnt work

Java ≠ JavaScript they are different languages

No the string substitution is a special syntax for the GarageSale Template language (a whole other language from AppleScript and JavaScript). You can only use the square brackets in GS templates.

Here is a little JavaScript that prints the brand, if there is one, to the console, or “NO BRAND” if there isn’t one set. The template language you are using is doing a lot of extra BS to check whether there is a Brand attribute at all. Don’t do that.

function run(){
  var thisBrand = "";
	for (const listing of selectedListings) {
	  thisBrand = listing.attributes["Brand"];
		if (!thisBrand) {
		  consoleLog("NO BRAND");
		} else {
		  consoleLog(thisBrand);		  
		}
	}
}

(This is not very well-factored JS; I just threw it together to show you how to get the attributes in JS.)

Hiya!! oh great thanks for this… Ill see if i can take that, and work out how to make the title… brand size colour etc.

Thanks!

Ah okay okay… sorry i used to use a different software and the [[ could be used everywhere…

Yeah that’s Shopify/Liquid template syntax.

@pkjack contacted me through the support with some request regarding adding certain attributes to the title so I tried to create one based on @Vaguery script. It might be helpful for others, too, that’s why I am posting it here. Feel free to modify and improve it to fit your needs.

function run() {

	var thisBrand = "";
	var thisSize = "";
	var thisColour = "";
	var thisPattern = "";
	var thisFeatures = "";
	var thisType = "";

	for (const listing of selectedListings) {

		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"] + " ";
		}

		if (!listing.attributes["Pattern"]) {
			consoleLog("NO PATTERN");
		} else {
			thisPattern = listing.attributes["Pattern"] + " ";
		}

		if (!listing.attributes["Features"]) {
			consoleLog("NO FEATURES");
		} else {
			thisFeatures = listing.attributes["Features"] + " ";
		}

		if (!listing.attributes["Type"]) {
			consoleLog("NO TYPE");
		} else {
			thisType = listing.attributes["Type"] + " ";
		}


		listing.title = "Text" + " " + thisBrand + thisSize + thisColour + thisPattern + thisFeatures + thisType + "Text";

	}
}

More about GarageSale’s javascript feature: Running Scripts

Regards, Kristian

Hiya!! you beat me to it… was just about to paste it here… going to run some tests & will update…

As a note for anyone looking at this… with the help from @Vaguery i managed to get to this stage this stage -

function run() {
consoleLog("selectedListings: " + selectedListings.length);
for (const listing of selectedListings) {
// consoleLog(listing.title);
listing.title = “Ladies” + " " + listing.attributes[“Brand”] + " " + “Size” + " " + listing.attributes[“Size”] + " " + listing.attributes[“Colour”] + " " + listing.attributes[“Neckline”] + " " + listing.attributes[“Sleeve Length”] + " " + listing.attributes[“Type”] + " " + “Top”
// consoleLog(listing.title);
}
}

The problem i had was if a attribute was missing it would read as undefined - this is where @Vaguery 2nd solution come into play with removing anything that was blank… but i could quite figure out how to implement into each other…

then @kristian put it all together…

:slight_smile:

@kristian perhaps we might find a channel (or whatever discourse has) for sharing tips and tricks and scripts?

1 Like

Perhaps another forum on here? for custom scripts?

I added a GarageSale Scripts category for all your script sharing needs.

1 Like

Hey Kristian. So. works great! the only thing is if lets say " pattern " doesnt have one… it adds an extra space into the title…

i know if i remove the space in - " " - that would do it… but then if there is a pattern, it needs a space…

Is there anyway around that?
All the best

If there’s no “Pattern” attribute no extra space should be added at all.
Can you please double-check?

I couldn’t reproduce this problem.

Regards, Kristian