fix:删除多余的图片

上级 ec591009
......@@ -22,33 +22,39 @@ import java.util.concurrent.TimeUnit;
@Slf4j
public class FileContains {
/**
* 默认不存在
*/
private static boolean IS_EXIST = false;
/**
* 图片路径
*/
private static final String PIC_PATH = "/Users/qinyingjie/Documents/idea-workspace/blogimg/";
/**
* 博客路径
*/
private static final String BLOG_FOLDER = "/Users/qinyingjie/Documents/idea-workspace/blog/";
public static void main(String[] args) throws IOException {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
final List<String> isNotExist = new ArrayList<>();
//获取picPath下面所有的文件名
String picPath = "/Users/qinyingjie/Documents/idea-workspace/blogimg/";
final List<String> picNames = getPicName(picPath);
final List<String> picNames = getPicName(PIC_PATH);
log.info("图片总数为{}", picNames.size());
for (String word : picNames) {
IS_EXIST = false;
//遍历某个文件夹下的所有以.vue结尾的文件
//博客文件夹
String folder = "/Users/qinyingjie/Documents/idea-workspace/blog/";
//指定类型的文件
String suffix = ".md";
//包含某个字符串
traverseFolder(folder, suffix, word);
traverseFolder(BLOG_FOLDER, suffix, word);
//文件不存在
if (!IS_EXIST) {
isNotExist.add(word);
deletePic(PIC_PATH + word);
}
}
log.info("不存在图片总数为{}", isNotExist.size());
for (String s : isNotExist) {
deletePic(picPath + s);
}
stopWatch.stop();
//毫秒输出
log.info(String.valueOf(stopWatch.getTime(TimeUnit.MILLISECONDS)));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册