Project/pyrmdup2017. 4. 24. 02:01

 

 

pyrmdup.exe
다운로드
pyrmdup_0424b.zip
다운로드

 

 

* 사용법

 

1) pyrmdup 폴더1 폴더2 ...

-> 중복 파일 리스트를 보여 줌

 

2) pyrmdup -m 폴더1 폴더2 ...

-> 중복 파일을 하나만 빼고, duplicate 폴더로 모아 줌

 

 

https://github.com/chobocho/pyrmdup


2022.12.28일 업데이트

V3 와 같은 백신이 설치 된 경우, 실행이 차단 되는 경우가 있습니다.

이 때, 실행이 되도록 허용 해주셔야 실행이 됩니다.

Posted by chobocho
Project/pyrmdup2017. 4. 24. 00:58

pyrmdup

중복파일을 제거하는 파이썬 스크립트

1. 기본 아이디어

검색할 폴더안의 파일들을 크기순으로 정렬 하여, 같은 크기가 2개 이상인 파일들을 그룹으로 묶기
같은 크기의 파일 그룹에 속한 파일들을 각각 1024바이트 씩 읽어서 같은 값인 파일들만 남기기
같은 그룹에 속한 파일들을 1:1로 비교

2. 구현

2.1 pyrmdup.py 생성

#-*- coding: utf-8 -*-

def main():
    print "Hello!"

if __name__ == '__main__':
   main()

2.2 옵션기능을 추가

-m : 발견된 중복 파일을 dupfiles 폴더로 옮김
-d : 자세한 로그를 출력하기
-h : 도움말을 보여줌

#-*- coding: utf-8 -*-
import sys

def main(folderlist):
    isMoveFile = False
    isDebugMode = False

    #Check option
    if '-m' in folderlist:
        isMoveFile = True
        folderlist.remove('-m')
        print "* Remove duplicated files"

    if '-d' in folderlist:
        isDebugMode = True
        folderlist.remove('-d')
        print "* Show file list"  

def printHelp():
    print "\n[Help]"
    print "Usage : pyrmdup [option] FolderName" 
    print "option:"
    print " -d : print log"
    print " -m : move all duplicated files to dupfiles folder"
    print " -h : show help message"

if __name__ == '__main__':
    if (len(sys.argv) < 2) or ('-h' in sys.argv[1:]):
        printHelp()
    else:
        main(sys.argv[1:])

2.3 실행 시간을 확인하기 위한 코드를 추가

#-*- coding: utf-8 -*-
import sys
import timeit

myVersion = '-V0.627_170423c- Time:'

def main(folderlist):
    isMoveFile = False
    isDebugMode = False

    #Check option
    if '-m' in folderlist:
        isMoveFile = True
        folderlist.remove('-m')
        print "* Remove duplicated files"

    if '-d' in folderlist:
        isDebugMode = True
        folderlist.remove('-d')
        print "* Show file list" 

def printHelp():
    print "\n[Help]"
    print "Usage : pyrmdup [option] FolderName" 
    print "option:"
    print " -d : print log"
    print " -m : move all duplicated files to dupfiles folder"
    print " -h : show help message"

if __name__ == '__main__':
    start_time = timeit.default_timer()
 
    if (len(sys.argv) < 2) or ('-h' in sys.argv[1:]):
        printHelp()
    else:
        main(sys.argv[1:])

    print '\n', myVersion, timeit.default_timer()-start_time

2.4 입력된 폴더의 모든 파일을 출력

#-*- coding: utf-8 -*-
import sys
import timeit
import os

myVersion = '-V0.627_170423c- Time:'

def main(folderlist):
    isMoveFile = False
    isDebugMode = False

    #Check option
    if '-m' in folderlist:
        isMoveFile = True
        folderlist.remove('-m')
        print "* Remove duplicated files"

    if '-d' in folderlist:
        isDebugMode = True
        folderlist.remove('-d')
        print "* Show file list" 

    folders = folderlist

    print '* Folders :'
    for f in folders:
        print f

    print "* Start read files"
  
    for folder in folders:
        if os.path.exists(folder):
            for (path, dir, files) in os.walk(folder):
                for filename in files:
                    tf = os.path.join(path, filename)
                    print tf
        else:
            print "Error:",folder," is not exist"       

def printHelp():
    print "\n[Help]"
    print "Usage : pyrmdup [option] FolderName" 
    print "option:"
    print " -d : print log"
    print " -m : move all duplicated files to dupfiles folder"
    print " -h : show help message"

if __name__ == '__main__':
    start_time = timeit.default_timer()
 
    if (len(sys.argv) < 2) or ('-h' in sys.argv[1:]):
        printHelp()
    else:
        main(sys.argv[1:])

    print '\n', myVersion, timeit.default_timer()-start_time

2.5 입력된 폴더의 모든 파일을 읽어서 같은 크기 끼리 그룹으로 묶음

#-*- coding: utf-8 -*-
import sys
import timeit
import os

myVersion = '-V0.627_170423c- Time:'

def main(folderlist):
    isMoveFile = False
    isDebugMode = False

    #Check option
    if '-m' in folderlist:
        isMoveFile = True
        folderlist.remove('-m')
        print "* Remove duplicated files"

    if '-d' in folderlist:
        isDebugMode = True
        folderlist.remove('-d')
        print "* Show file list" 

    folders = folderlist

    print '* Folders :'
    for f in folders:
        print f

    print "* Start read files"
    dict = {}    #폴더안의 모든 파일을 읽어서, Kye=이름:value=크기 로 저장 
    result = {}  #중복 파일 리스트를 저장하기 위한 변수
  
    for folder in folders:
        if os.path.exists(folder):
            for (path, dir, files) in os.walk(folder):
                for filename in files:
                    tf = os.path.join(path, filename)
                    if isDebugMode: print tf
                    dict[tf] = os.path.getsize(tf);
                    if isDebugMode: print ("%s : %d" % (tf, dict[tf]))

                    if result.get(dict[tf]) == None:
                        result[dict[tf]] = 1
                    else:
                        result[dict[tf]] += 1 
        else:
            print "Error:",folder," is not exist"                

def printHelp():
    print "\n[Help]"
    print "Usage : pyrmdup [option] FolderName" 
    print "option:"
    print " -d : print log"
    print " -m : move all duplicated files to dupfiles folder"
    print " -h : show help message"

if __name__ == '__main__':
    start_time = timeit.default_timer()
 
    if (len(sys.argv) < 2) or ('-h' in sys.argv[1:]):
        printHelp()
    else:
        main(sys.argv[1:])

    print '\n', myVersion, timeit.default_timer()-start_time


Posted by chobocho
Project/ChoboCalendar2017. 4. 23. 23:57

ChoboCalendar  앱은 어떠한 개인 정보도 수집하지 않습니다.

ChoboCalendar does not collect any personal information.

 

 

 

 

 

ChoboCalendar_20170423b.apk
다운로드

 

 

Posted by chobocho
Project/pyrmdup2017. 4. 23. 03:45

pyrmdup.exe

pyrmdup_0423c.zip



* 사용법


1) pyrmdup 폴더1 폴더2 ...

-> 중복 파일 리스트를 보여 줌


2) pyrmdup -m 폴더1 폴더2 ...

-> 중복 파일을 하나만 빼고, duplicate 폴더로 모아 줌



https://github.com/chobocho/pyrmdup



Posted by chobocho
Project/pyrmdup2017. 4. 18. 01:05

* 폴더안의 중복 파일들을 제거 하는앱


* 전체 소스 : https://github.com/chobocho/pyrmdup 



* 아이디어 : 크기순 정렬 -> 1024 바이트씩 읽어서 해쉬값으로 사용


1. 폴더안의 모든 파일 읽기


2. 같은 크기의 파일끼리 모으기

    - List 1 :  크기가 65536 이상인 파일

    - List 2 :  크리가 65535 미만인 파일


3. 각각의 리스트에서 같은 크기의 파일이 2개 이상인, 파일들만 남기기

 

4. 각각의 리스트의 파일에서 1024 바이트씩 읽어서, 같은 값인 파일끼리 모으기 


5. List 1의 남은 파일 : 전수 비교


6. List 2의 남은 파일 : MD5 Hash 비교  


7. 같은 크기의 파일을 출력하기



update : 2017.4.23

Posted by chobocho
Project/pyrmdup2017. 4. 14. 03:03

pyrmdup.exe

pyrmdup_0423a.zip



* 사용법


1) pyrmdup 폴더1 폴더2 ...

-> 중복 파일 리스트를 보여 줌


2) pyrmdup -m 폴더1 폴더2 ...

-> 중복 파일을 하나만 빼고, duplicate 폴더로 모아 줌



https://github.com/chobocho/pyrmdup




update: 2017. 4. 23

Posted by chobocho
My Life/version 17 (2017)2017. 3. 31. 01:46




'My Life > version 17 (2017)' 카테고리의 다른 글

2018년 지름 정리  (0) 2019.01.05
한국사능력시험 1급 합격  (0) 2017.09.05
Kool tool  (0) 2017.07.07
Posted by chobocho
Coding/JavsScript 삽질기2017. 3. 31. 00:45

* Javascript로 만든 계산기

http://www.chobocho.com/javascript/calc.html


* 문법

   # : 주석

   변수 수식 ::= 변수에 수식을 대입한다

   = 수식 ::= 수식을 계산한다 


* Source : https://github.com/chobocho/Calc

'Coding > JavsScript 삽질기' 카테고리의 다른 글

공백을 제거해주는 스크립트  (0) 2018.04.02
Sam Loyd's unsolvable 15-puzzle  (0) 2017.02.05
Puzzle game  (0) 2017.01.22
Posted by chobocho
Travel/2016 Norway2017. 2. 5. 20:36
품목 세부품목
여권 여권
  여권사본
  증명사진
지사제
  감기약
  반창소
  마스크
셔츠
  바지
  런닝
  팬츠
  손수건
  외투
노트북 노트북
  충전기
휴대폰 휴대폰
  충전기
  외장배터리
신용카드  
명함  
세면도구 치솔
  치약
  면도기
  비누
  손톱깎기
작은 손 가방  
환전  
우산  


출장 체크 리스트.xlsx


'Travel > 2016 Norway' 카테고리의 다른 글

송요 피오르드  (0) 2016.03.30
Oslo 교통카드  (0) 2016.03.03
Nut shell tour  (0) 2016.03.03
Posted by chobocho



[ http://www.chobocho.com/javascript/puzzle_4x4_impossible.html ]

'Coding > JavsScript 삽질기' 카테고리의 다른 글

Chobocho Calc 2  (0) 2017.03.31
Puzzle game  (0) 2017.01.22
Simple calculator  (0) 2016.10.28
Posted by chobocho