String (@NotNull VirtualFile dir, @NotNull String prefix, @NotNull String extension) { String dotExt = PathUtil.makeFileName("", extension); String fileName = prefix + dotExt; int i = 1; while (dir.findChild(fileName) != null) { fileName = prefix + "_" + i + dotExt; i++; } return fileName; }