Checks if name exists in array exist_file_names and if yes returns nextified file name.

E.g. image.jpg -> image1.jpg -> image2.jpg

nextify_name(name, exist_file_names) {
    // check name not takan
    var free = false;
    while (! free) {
        exist_filen_names.forEach( (f) => {
            if (f == name) {
                var match = name.match(/\d+$/);
                if (match && match.length) {
                    var num = match[0];
                    name = name.slice(0, name.length - num.length) + (parseInt(num) + 1);
                } else {
                    name = name + "1"
                }
            }
        });
        free = true;
    }
    return name
}