Thanks,
Russ
//----------------------------------- // Update Ads for 2012 // Created By: Russ Savage // FreeAdWordsScripts.com //----------------------------------- function main() { var OLD_YEAR = "2011"; var NEW_YEAR = "2012"; //You probably shouldn't update destination urls unless you know what you are doing. var FIELDS_CONTAINING_YEAR = ["Headline","Description1", "Description2","DisplayUrl" /*,"DestinationUrl"*/ ]; for(i in FIELDS_CONTAINING_YEAR) { var field_iter = AdWordsApp.ads() .withCondition(FIELDS_CONTAINING_YEAR[i] + " CONTAINS " + OLD_YEAR) .withCondition("Status = ENABLED") .get(); _iterateThroughAds(field_iter); } //--------------- // Private Helper Functions //--------------- function _iterateThroughAds(ad_iter) { while (ad_iter.hasNext()) { var ad = ad_iter.next(); var ag = ad.getAdGroup(); _createNewAdFromOldAd(ag,ad); } } function _createNewAdFromOldAd(adgroup, old_ad) { //get the updated ad texts replacing all the old years with the new years var new_headline = old_ad.getHeadline().replace(OLD_YEAR,NEW_YEAR); var new_desc1 = old_ad.getDescription1().replace(OLD_YEAR,NEW_YEAR); var new_desc2 = old_ad.getDescription2().replace(OLD_YEAR,NEW_YEAR); var new_display_url = old_ad.getDisplayUrl().replace(OLD_YEAR,NEW_YEAR); var new_dest_url = old_ad.getDestinationUrl();/*.replace(OLD_YEAR,NEW_YEAR);*/ //now create the new ad and pause the old one. adgroup.createTextAd(new_headline,new_desc1,new_desc2,new_display_url,new_dest_url); old_ad.pause(); } }