浏览代码

将身份照号码转为大写

Michael Wang 6 年之前
父节点
当前提交
9b26fa9823
共有 1 个文件被更改,包括 13 次插入0 次删除
  1. 13 0
      src/views/index.vue

+ 13 - 0
src/views/index.vue

@@ -85,6 +85,19 @@ function isImageFile(fileName) {
 
 //读取文件,返回网站路径. 只扫描当前文件夹,不递归扫描
 function readImageFiles(folderPath) {
+  try {
+    const filesToRename = fs.readdirSync(folderPath);
+    filesToRename
+      .filter(isImageFile)
+      .forEach(fileName =>
+        fs.renameSync(
+          folderPath + "/" + fileName,
+          folderPath + "/" + fileName.toUpperCase()
+        )
+      );
+  } catch (e) {
+    alert("将身份证号转为大写出错。");
+  }
   const files = fs.readdirSync(folderPath);
   return files
     .filter(isImageFile)