How to use the renameSync function from fs
Find comprehensive JavaScript fs.renameSync code examples handpicked from public code repositorys.
93 94 95 96 97 98 99 100 101 102let srcFilePath = path.join(src, entry), destFilePath = path.join(dest, entry); if (entry === 'favicon.ico') { // Skip it. } else if (entry !== 'index.html') { fs.renameSync(srcFilePath, destFilePath); } else { copyIndex(srcFilePath, dest); } }
GitHub: blockcollider/bcnode

78 79 80 81 82 83 84 85 86 87exports.readlink = co.promisify(fs.readlink); exports.readlinkSync = fs.readlinkSync; exports.realpath = co.promisify(fs.realpath); exports.realpathSync = fs.realpathSync; exports.rename = co.promisify(fs.rename); exports.renameSync = fs.renameSync; exports.rmdir = co.promisify(fs.rmdir); exports.rmdirSync = fs.rmdirSync; exports.stat = co.promisify(fs.stat); exports.statSync = fs.statSync;
GitHub: riwsky/bucklescript

38 39 40 41 42 43 44 45 46* @param {string} from * @param {string} to */ function poor_copy_sync(from,to){ console.log(from , '----->', to) fs.renameSync(from,to) // fs.renameSync(from,to) }
+ 5 other calls in file
42 43 44 45 46 47 48 49 50* @param {string} from * @param {string} to */ function poor_copy_sync(from, to) { console.log(from, '----->', to) fs.renameSync(from, to) // fs.renameSync(from,to) }
+ 5 other calls in file
293 294 295 296 297 298 299 300 301 302}, _housekeepingSync: function (outputFileFolderWithoutSlash, outputFileName) { const tempFilePath = `${tempDir}/${outputFileName}`; if (fs.existsSync(tempFilePath)) { fs.renameSync(tempFilePath, `${outputFileFolderWithoutSlash}/${outputFileName}`); fs.readdirSync(outputFileFolderWithoutSlash).forEach((foundFile) => { if (foundFile !== outputFileName) { fs.unlinkSync(`${outputFileFolderWithoutSlash}/${foundFile}`); }
+ 12 other calls in file
298 299 300 301 302 303 304 305 306 307 308 309const destFile = path.join(tmpdir.path, 'foo'); fs.rename(nonexistentFile, destFile, common.mustCall(validateError)); assert.throws( () => fs.renameSync(nonexistentFile, destFile), validateError ); }
+ 3 other calls in file
GitHub: Giftia/ChatDACS
1573 1574 1575 1576 1577 1578 1579 1580 1581 1582app.post("/upload/image", upload.single("file"), function (req) { logger.info("用户上传图片".log); logger.info(req.file); const oldname = req.file.path; const newname = req.file.path + path.parse(req.file.originalname).ext; fs.renameSync(oldname, newname); io.emit("picture", { type: "picture", content: `/uploads/${req.file.filename}${path.parse(req.file.originalname).ext}` }); });
418 419 420 421 422 423 424 425 426 427renameFile(id_old, id_new) { try { const path_old = USERDATA_PATH + id_old + ".svg"; const path_new = USERDATA_PATH + id_new + ".svg"; fs.renameSync(path_old, path_new); this.log("Icon reamed: from "+path_old+" to"+path_new); } catch(error) { this.log("Error renaming device icon: "+path_old+" to"+path_new); }
81 82 83 84 85 86 87 88 89 90 91 92const unlinkFileSync = path => { if (!isWindows) return fs.unlinkSync(path) const name = path + '.DELETE.' + crypto.randomBytes(16).toString('hex') fs.renameSync(path, name) fs.unlinkSync(name) } // this.gid, entry.gid, this.processUid
GitHub: AxelRothe/wranglebot
588 589 590 591 592 593 594 595 596 597* * @param pathToElement * @param newFolder */ move(pathToElement, newFolder) { return fs.renameSync(pathToElement, this.join(newFolder, this.basename(pathToElement))); } /** * Rename a file and move it, returns true if the file was moved
+ 2 other calls in file
GitHub: emodamage/node_api
496 497 498 499 500 501 502 503 504 505// body [Object: null prototype] { test: 'test1111' } let file = req.files[0] let path = 'public/image/' + username + '.' + file.originalname.split('.')[1] // 覆盖 fs.renameSync('./public/image/' + file.filename, path); let fileInfo = {} fileInfo.type = file.mimetype fileInfo.name = file.originalname
+ 2 other calls in file
496 497 498 499 500 501 502 503 504 505retry_download = false; let f = files[0]; console.log('rename downloaded subtitle file -->' + f); let newName = f.replace(/\(|\)|\'|\s+|-/g, ''); console.log('new file name -->' + newName); fs.renameSync(download_dir + f, download_dir + newName); let output_file = download_dir + newName + '.2.srt'; fs.access(output_file, (err) => { if (!err) { console.log('output file exists, remove it');
236 237 238 239 240 241 242 243 244 245}); } else { // video content newPathStr = `uploads/${user}/${req.files[i].filename}`; fs.renameSync(oldPath, newPathStr, function (err) { if (err) throw err; newPath.push(newPathStr); }); if (typeof req.files !== 'undefined') {
305 306 307 308 309 310 311 312 313 314); // Write to file const REPLAY_JSON = JSON.stringify(REPLAY, undefined, 2); fs.writeFileSync(workFile, REPLAY_JSON); fs.renameSync(`replays/${file}.replay`, `replays/processed/${file}.replay`); execSync( `bin\\rattletrap-12.0.1-windows.exe -m encode -i "${workFile}" -o "replays/out/${file}.anonymous.replay"` );
8 9 10 11 12 13 14 15 16 17} else { const { originalname, path } = req.file; const parts = originalname.split("."); const ext = parts[parts.length - 1]; const newPath = path + "." + ext; fs.renameSync(path, newPath); const { token } = req.cookies; jwt.verify(token, secret, {}, async (err, info) => { if (err) throw err;
+ 7 other calls in file
GitHub: pb-it/wing-cms-api
805 806 807 808 809 810 811 812 813 814if (fileName) { if (old && old[str] && old[str] != fileName) { var oldFile = path.join(localPath, old[str]); var newFile = path.join(localPath, fileName); if (fs.existsSync(oldFile) && !fs.existsSync(newFile)) fs.renameSync(oldFile, newFile); } } else { if (old && old[str]) { var file = path.join(localPath, old[str]);
97 98 99 100 101 102 103 104 105binaryFileName = 'direcbase'; break; } const executablePath = path.resolve(__dirname, '../lib/',binaryFileName); fs.renameSync( path.join(projectDir, 'env.sample'), path.join(projectDir, '.env') );
fs.readFileSync is the most popular function in fs (2736 examples)
