Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

11
LINES

< > BotCompany Repo | #1018665 // makeFileNameUnique_space (by adding " 2", " 3", ...)

JavaX fragment (include)

static File makeFileNameUnique_space(File f) {
  S ext = fileExtension(f);
  File orig = f;
  int n = 1;
  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;
}

Author comment

Began life as a copy of #1016338

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1018665
Snippet name: makeFileNameUnique_space (by adding " 2", " 3", ...)
Eternal ID of this version: #1018665/1
Text MD5: 9a0b6b0c2ed77ff8e0343ad2be944476
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:38:12
Source code size: 352 bytes / 11 lines
Pitched / IR pitched: No / No
Views / Downloads: 345 / 359
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)