Unterordner werden nicht umbenannt.

Hi,

die eigentliche Logik ist nur wenige Zeilen lang:
Java:
// Recursivly list all directories which have the searched name
final List<Path> matches = Files.find(target, 10, (path, attr) -> (attr.isDirectory() && path.endsWith(search)))
		.sorted().collect(Collectors.toList());

// reverse the result list
Collections.reverse(matches);

// loop over the found folders
for (final Path oldName : matches) {
	// create the new name
	final Path newName = oldName.resolveSibling(replace);

	// rename them
	Files.move(oldName, newName, StandardCopyOption.ATOMIC_MOVE);

	// some log output
	System.out.printf("%-25s => %s\n", oldName, newName);
}

Komplett mit simplen Test: https://gist.github.com/bratkartoffel/e07f66010aa396f3cb7a

Grüsse,
BK
 
Zurück