Skip to content

@sqlrooms/utils / generateUniquePath

Function: generateUniquePath() ​

generateUniquePath(filePath, existingPaths): string

Generates a unique file path by appending a numeric suffix if the path already exists.

Parameters ​

ParameterTypeDescription
filePathstringThe original file path
existingPathsstring[]Array of existing file paths to check against

Returns ​

string

A unique file path

Example ​

ts
generateUniquePath("file.txt", ["file.txt"]) // returns "file_1.txt"