Skip to content

Instantly share code, notes, and snippets.

@ahmetaa
Last active May 2, 2017 08:07
Show Gist options
  • Save ahmetaa/412cdec3301df9bf7518167d864943c5 to your computer and use it in GitHub Desktop.
Save ahmetaa/412cdec3301df9bf7518167d864943c5 to your computer and use it in GitHub Desktop.
copy stuff
public class CopyStuff {
public static void main(String[] args) throws IOException {
Path sourceRoot = Paths.get("/home/aaaa/prototip/exec"); // normalde kullanılan dosyalar bu exec dizininde
Path kaldiSrcRoot = Paths.get("/home/aaaa/apps/kaldi/src"); // kaldi src dizini yolu.
Path targetRoot = Paths.get("/home/aaaa/prototip/exec-new"); // yeni dosyaların kaydedileceği dizin.
// dosya isimlerini topla.
Set<String> paths = Files.walk(sourceRoot)
.filter(s -> s.toFile().isFile())
.map(s -> s.toFile().getName())
.collect(Collectors.toSet());
// kaldi src içerisinde yürü ve aynı isme sahip dosyaları bul.
List<Path> result = Files.walk(kaldiSrcRoot, 2)
.filter(s -> s.toFile().isFile() && paths.contains(s.toFile().getName()))
.collect(Collectors.toList());
// bunları hedefe kaydet.
Files.createDirectories(targetRoot);
for (Path path : result) {
Files.copy(path, targetRoot.resolve(path.getFileName()));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment