I am using SMBClient
to connect to my SMB server with Java.
How can I recursively scan my entire SMB share to get a listing of all files with an .mp4 extension?
This is my code that only scans the one designated directory:
private void btnFileCountActionPerformed(java.awt.event.ActionEvent evt) {
SMBClient client = new SMBClient();
try (Connection connection = client.connect("192.168.X.XXX")) {
AuthenticationContext ac = new AuthenticationContext("XXXXXXX@hotmail.com", "XXXXXX".toCharArray(), "Mastafin");
Session session = connection.authenticate(ac);
try (DiskShare share = (DiskShare) session.connectShare("Folder With Spaces")) {
for (FileIdBothDirectoryInformation f : share.list("LOTS OF SUBDIRS TO SCAN", "*.mp4")) {
System.out.println("File : " + f.getFileName());
}
} catch (Exception e) {
System.out.println(e);
}
} catch (Exception e) {
System.out.println(e);
}
}