Created
November 25, 2019 19:16
-
-
Save trevorfoskett/4a653db1cc8372461c8c5dc6758c51ec to your computer and use it in GitHub Desktop.
Assigning a unique filename if filename already exists.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var i = 1; | |
var array = fileName.split('.'); | |
var encryptFileName = `${array[0]}.${array[1]}.tdf3.html`; | |
while (fs.existsSync(`./encrypt-out/${encryptFileName}`)) { | |
encryptFileName = `${array[0]} (${i}).${array[1]}.tdf3.html`; | |
i++; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment