try this code:
function copyAndDelete() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var source = ss.getRange('E6:I6');
var range1 = ss.getRange('E6');
var range2 = ss.getRange('G6');
var vals = ss.getRange("E13:I17").getValues();
var destinationRow = 13;
for (var i in vals){
var rowVal = vals[i].join();
rowVal = rowVal.replace(/,/gm,"");
Logger.log(rowVal);
if(rowVal==""){
destinationRow=13+Number(i);
ss.getRange("E"+destinationRow+":I"+destinationRow).setValues(source.getValues());
range1.clearContent();
range2.clearContent();
return;
}
}
throw("no empty row found :-(");
}
You didn't specified what to do when there is no empty row in E13:I17, so I decided to throw an error and not perform the copy action in this case.