2024/02/03 19:29:19
顶级域名的home页部署完毕,至此“麻雀”已然成形
2024/01/28 12:10:14
物理创造世界,代码改变世界,金钱畅游世界。
2024/01/24 08:54:03
雪,天空给以洁白,却又任其在黑夜起舞。
2024/01/24 08:53:21
2023/12/17 13:54:14
2023/12/14 19:47:10
2023/12/09 12:01:51
/**
*文件名:renamae.js
*执行:node rename.js
*功能说明:将webp文件重名为prefix+8个随机字符串的名字
*示例:prefix_4zEqS8fw.webp
*/
const fs = require('fs');
const reg = /\.webp$/i;
const prefix = "prefix_"
fs.readdir(__dirname,(err,files)=>{
if(err){
console.log(err);
}else{
files.forEach(file=>{
if(reg.test(file)){
var oldFileName = file;
var newFileName = prefix + randomRange(8) + ".webp";
fs.rename(oldFileName,newFileName,(err)=>{
if(err){
console.log("重命名失败");
}else{
console.log(oldFileName + "重命名成功,新文件名为:" + newFileName+"。\n");
}
});
}
})
}
})
/** 随机生成固定位数或者一定范围内的字符串数字组合
* @param {Number} min 范围最小值
* @param {Number} max 范围最大值,当不传递时表示生成指定位数的组合
* @returns {String} 返回字符串结果
* */
function randomRange(min, max){
var returnStr = "",
range = (max ? Math.round(Math.random() * (max-min)) + min : min),
charStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for(var i=0; i<range; i++){
var index = Math.round(Math.random() * (charStr.length-1));
returnStr += charStr.substring(index,index+1);
}
return returnStr;
}
2023/12/05 16:22:28
2023/12/03 23:07:06
东方Project:https://img.paulzzh.tech/
likepoems随机图:https://api.likepoems.com/
Unsplash Image:https://source.unsplash.com/
缙哥哥博客:https://api.dujin.org/pic/yuanshen/
LoliAPI:https://www.loliapi.com/
EEE.DOG:https://api.yimian.xyz/
2023/11/30 19:45:24
加入51a网站统计