This small toy extract all Windows 10 lockscreen images to a folder on your desktop, and adds a .jpg file extension for easy viewing.
usage:
- Download the jar file at the end of this document to a folder of your choosing
- Execute from a command prompt with ‘java LockscreenExtract’
- Your desktop now has a folder called ‘Extract’ with your images
import java.io.File;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class Main {
private static String OFFSET_DIR = "\\Packages\\Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy\\LocalState\\Assets";
/**
* Extract the windows lockscreen wallpapers to the desktop, and gives the files an extension to make them
* viewable. Extraction is done for files larger then 100.000 bytes, so we end up with the actual wallpapers
* while skipping thumbnails and other small stuff.
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
String basedir = System.getenv("LOCALAPPDATA");
String sourceHandle = basedir + OFFSET_DIR;
String targetHandle = System.getenv("USERPROFILE") + "\\Desktop\\Extract";
Path sourcePath = Paths.get(sourceHandle);
Path targetPath = Paths.get(targetHandle);
System.out.println("Source :" + sourceHandle);
System.out.println("Target :" + targetHandle);
if (!Files.exists(targetPath)) {
Files.createDirectory(targetPath);
}
try (DirectoryStream<Path> stream = Files.newDirectoryStream(sourcePath, "*")) {
for (Path entry : stream) {
// Require at least 100k bytes to filter out icons and stuff
File checkHandle = new File(String.valueOf(entry));
if (checkHandle.length() > 100000) {
// rename to jpg to make the image accessible
String targetName = entry.getFileName() + ".jpg";
Path copyTo = Paths.get(targetPath + "\\" + targetName);
// only new files we dont have yet
if (!Files.exists(copyTo)) {
Files.copy(entry, copyTo);
System.out.println("nieuw: " + entry.getFileName());
} else {
System.out.println("skipped: " + entry.getFileName());
}
}
}
}
}
}