Created
May 13, 2012 09:06
-
-
Save ojimac/2687081 to your computer and use it in GitHub Desktop.
Macで、カレントディレクトリ内の内容が重複しているファイルを削除するスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import os | |
import re | |
files = os.listdir('./') | |
for file in files: | |
if re.match('[0-9a-zA-z]+\s2\.[JPG|CR2]', file): | |
os.remove(file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
macでは、同じディレクトリ内に同じファイル名のファイルをコピーすると、
ファイル名_2.拡張子
※ _ は半角スペース
のようなファイル名になる。
今回はデジカメで撮った写真(JPG, CR2)が重複してしまった。
一個一個消していくのは面倒なのでスクリプトにしてみた。