Created
May 29, 2022 16:04
-
-
Save BerkeKaragoz/5b53c1cee988a0138da1840f20adb378 to your computer and use it in GitHub Desktop.
Replaces the symlinks with their targets
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
// Replaces the symlinks with their targets | |
var fs = require("fs"); | |
fs.readdir(__dirname, (err, files) => { | |
if (err) console.log(err); | |
else { | |
console.log("\nCurrent directory filenames: ", files); | |
files.forEach((file) => { | |
fs.readlink(file, (err, linkString) => { | |
if (err) return; | |
console.log("Path of the symlink:", linkString); | |
fs.rename(linkString, file, (error) => { | |
if (error) console.log(error); | |
else console.log("\nFile moved: ", file); | |
}); | |
}); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment