| | |
| | | /* |
| | | neon-fm - File management extensions to Neon |
| | | fm - File management class library |
| | | Copyright (C) 2024 Ulrich Hilger |
| | | |
| | | This program is free software: you can redistribute it and/or modify |
| | |
| | | |
| | | public static final String STR_DOT = "."; |
| | | |
| | | public String umbenennen(HttpExchange exchange, String relPfad, String neuerName, File file) throws IOException { |
| | | public String umbenennen(/*HttpExchange exchange, */String relPfad, String neuerName, File file) |
| | | throws IOException { |
| | | File neueDatei; |
| | | //String relPfad = helper.getFileName(exchange); |
| | | //File file = new File(exchange.getHttpContext().getAttributes().get(FileHandler.ATTR_FILE_BASE).toString(), relPfad); |
| | | String fname = file.getName().toLowerCase(); |
| | | if(fname.endsWith(Const.JPEG) || fname.endsWith(Const.JPG) || fname.endsWith(Const.PNG)) { |
| | | if(fname.endsWith(ImageFileFilter.JPEG) || fname.endsWith(ImageFileFilter.JPG) || |
| | | fname.endsWith(ImageFileFilter.PNG)) { |
| | | neueDatei = renameImgFiles(file.getParentFile(), file, neuerName); |
| | | } else { |
| | | neueDatei = new File(file.getParentFile(), neuerName); |
| | |
| | | String ext = fnameext.substring(dotpos); |
| | | //logger.fine("fname: " + fname + ", ext: " + ext); |
| | | |
| | | DirectoryStream<Path> stream = Files.newDirectoryStream(targetDir.toPath(), fname + "*" + ext); //"*.{txt,doc,pdf,ppt}" |
| | | DirectoryStream<Path> stream = Files.newDirectoryStream(targetDir.toPath(), fname + "*" + ext); |
| | | for (Path path : stream) { |
| | | //logger.fine(path.getFileName().toString()); |
| | | alt = path.getFileName().toString(); |
| | | //logger.fine("alt: " + alt); |
| | | if(alt.contains(Const.TN)) { |
| | | neu = newfname + Const.TN + newext; |
| | | } else if (alt.contains(Const.KL)) { |
| | | neu = newfname + Const.KL + newext; |
| | | } else if(alt.contains(Const.GR)) { |
| | | neu = newfname + Const.GR + newext; |
| | | } else if(alt.contains(Const.MT)) { |
| | | neu = newfname + Const.MT + newext; |
| | | } else if(alt.contains(Const.SM)) { |
| | | neu = newfname + Const.SM + newext; |
| | | if(alt.contains(ImageFileFilter.TN)) { |
| | | neu = newfname + ImageFileFilter.TN + newext; |
| | | } else if (alt.contains(ImageFileFilter.KL)) { |
| | | neu = newfname + ImageFileFilter.KL + newext; |
| | | } else if(alt.contains(ImageFileFilter.GR)) { |
| | | neu = newfname + ImageFileFilter.GR + newext; |
| | | } else if(alt.contains(ImageFileFilter.MT)) { |
| | | neu = newfname + ImageFileFilter.MT + newext; |
| | | } else if(alt.contains(ImageFileFilter.SM)) { |
| | | neu = newfname + ImageFileFilter.SM + newext; |
| | | } else { |
| | | neu = newName; |
| | | } |