Created
April 1, 2022 16:01
-
-
Save lawvs/a4c504f0a40204285a0d50c37cbb28a0 to your computer and use it in GitHub Desktop.
Recovery file from .CHK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require("fs"); | |
const { exec } = require("child_process"); | |
const files = fs.readdirSync(__dirname); | |
files | |
.filter((i) => i.endsWith(".CHK")) | |
.forEach((i) => { | |
exec("file " + i, (err, stdout, stderr) => { | |
if (stdout.includes("JPEG")) { | |
exec("mv " + i + " " + i.replace(".CHK", ".jpg")); | |
return; | |
} | |
if (stdout.includes("PNG")) { | |
exec("mv " + i + " " + i.replace(".CHK", ".png")); | |
return; | |
} | |
if (stdout.includes("MP4")) { | |
exec("mv " + i + " " + i.replace(".CHK", ".mp4")); | |
return; | |
} | |
if (stdout.includes("Excel")) { | |
exec("mv " + i + " " + i.replace(".CHK", ".xls")); | |
return; | |
} | |
if (stdout.includes("PDF")) { | |
exec("mv " + i + " " + i.replace(".CHK", ".pdf")); | |
return; | |
} | |
if (stdout.includes("executable")) { | |
exec("mv " + i + " " + i.replace(".CHK", ".exe")); | |
return; | |
} | |
console.log(stdout); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment