             task.resume()
         }
         downloadGroup.wait()
+        
+        guard try fileManager.contentsOfDirectory(atPath: destinationBaseURL.path).count > 0 else {
+            print("Removing empty directory for radical \(id)")
+            try fileManager.removeItem(at: destinationBaseURL)
+            continue
+        }
         
         let imagesetContents = """
             {

        fileManager.createFile(atPath: destinationBaseURL.appendingPathComponent("Contents.json").path, contents: imagesetContents, attributes: nil)
    }
}
print("Done")

    """.data(using: .utf8)
fileManager.createFile(atPath: imageURL.appendingPathComponent("Contents.json").path, contents: contents, attributes: nil)

let expectedContentType = "image/png"

for level in 1...60 {
    let resources = try resourceRepository.loadSubjects(type: .radical, level: level)
    print("Level \(level): \(resources.count) radicals")
    for resource in resources {
        let id = resource.id
        let radical = resource.data as! Radical
        let renderableImages = radical.characterImages.filter({ $0.contentType == expectedContentType })
        if renderableImages.isEmpty {
            print("Skipping radical \(id): no renderable images")
            continue
