static File makeFileNameUnique_withExtension(File f, S ext) { File orig = f; int n = 0; ext = addPrefixIfNempty(".", dropPrefix(".", ext)); S name = dropSuffixIC(ext, orig.getName()); f = new File(dirOfFile(orig), name + ext); while (f.exists()) f = new File(dirOfFile(orig), name + "." + (++n) + ext); ret f; }
Began life as a copy of #1015318
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1016338 |
Snippet name: | makeFileNameUnique_withExtension (by adding .1, .2, .3...) |
Eternal ID of this version: | #1016338/5 |
Text MD5: | 2f324403be0b46e89483e2503dbfab0b |
Author: | stefan |
Category: | javax / io |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-10-08 12:36:35 |
Source code size: | 338 bytes / 10 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 466 / 490 |
Version history: | 4 change(s) |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) #1018665 - makeFileNameUnique_space (by adding " 2", " 3", ...) #1019315 - makeDirNameUnique_startWithOne (uses .1, .2, ...) |