<commit_before>---
layout: post
title: 링크깨진파일찾기
category: Life Style
keywords: 
tags: [파이썬,python]
---

{% highlight python linenos %}
import os
basePath = '/work/myblog/attachments'
basePath = '/work/myblog/attachments'
trashPath = '/work/myblog/not_attachments'
os.makedirs(trashPath,exist_ok=True)
attaches = [ x for x in os.listdir(basePath) if os.path.isfile(basePath + "/"+x)]
attaches_tmp = [ x for x in attaches]
print(attaches)
from glob import glob
paths = glob('/work/myblog/_posts/*')
for target in glob('/work/myblog/_posts/**/*.md'):
    f=open(target,"r",encoding="utf-8")
    for line in f.readlines():
        for item in attaches_tmp:
            if item in line :
                print("{} found in target : {}".format(item,target))
                attaches_tmp.remove(item)
for trash in attaches_tmp:
    os.rename(basePath + "/" +trash, trashPath + "/" + trash)
{% endhighlight %}


```python
print("hello")

```<commit_msg>글 내용을 gist 로 변경<commit_after>---
layout: post
title: 링크깨진파일찾기
category: Life Style
keywords: 
tags: [파이썬,python]
---

jekyll 을 사용하면서 attachments 폴더의 내용들이 본문과 달라서 정리가 필요할때 작성한 스크립트.

<script src="https://gist.github.com/dosuser/243e563e4ca331cca5005fd103da21e7.js"></script>
{'fraction_non_alphanumeric': 0.1510673234811166, 'fraction_numerical': 0.017241379310344827, 'mean_word_length': 3.7992125984251968, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2269026', 'n_tokens_mistral': 505, 'n_tokens_neox': 529, 'n_words': 108}