From 53b1d8d0fa3a3b3b96abae4c35b34ad1428f1a01 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 14 Nov 2023 12:50:34 +0100 Subject: [PATCH] Deleted old scripts --- create_test_structure.py | 46 ---------------------------------------- delete_duplicates.sh | 35 ------------------------------ 2 files changed, 81 deletions(-) delete mode 100644 create_test_structure.py delete mode 100755 delete_duplicates.sh diff --git a/create_test_structure.py b/create_test_structure.py deleted file mode 100644 index ec7da40..0000000 --- a/create_test_structure.py +++ /dev/null @@ -1,46 +0,0 @@ -import os -import shutil -import hashlib -import random -import string - -def create_test_directory(base_dir, num_files=5, duplicate_files=2): - if not os.path.exists(base_dir): - os.makedirs(base_dir) - - # Erstelle eine Liste von eindeutigen Dateinamen - file_names = [f"file_{i}.txt" for i in range(num_files)] - - # Erstelle einige Dateien mit zufälligem Inhalt - for file_name in file_names: - with open(os.path.join(base_dir, file_name), 'w') as f: - content = ''.join(random.choices(string.ascii_lowercase, k=20)) - f.write(content) - - # Erstelle Duplikate - for i in range(duplicate_files): - original = os.path.join(base_dir, file_names[i]) - duplicate = os.path.join(base_dir, f"dup_{file_names[i]}") - shutil.copyfile(original, duplicate) - -def create_file_structure(): - # Basisverzeichnisse erstellen - base_dirs = ['test_dir1', 'test_dir2'] - for base_dir in base_dirs: - create_test_directory(base_dir) - - # Erstelle eine Datei im ersten Verzeichnis und dupliziere sie im zweiten - with open(os.path.join('test_dir1', 'unique_file.txt'), 'w') as f: - f.write("This is a unique file.") - - shutil.copyfile(os.path.join('test_dir1', 'unique_file.txt'), - os.path.join('test_dir2', 'unique_file.txt')) - - # Erstelle eine zusätzliche einzigartige Datei im zweiten Verzeichnis - with open(os.path.join('test_dir2', 'another_unique_file.txt'), 'w') as f: - f.write("This is another unique file.") - - print("Test file structure created.") - -if __name__ == "__main__": - create_file_structure() diff --git a/delete_duplicates.sh b/delete_duplicates.sh deleted file mode 100755 index f4802aa..0000000 --- a/delete_duplicates.sh +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/bash - -if [ -z "$1" ] -then - echo "Directory path not provided" - exit 1 -fi - -dir="$1" -duplicates=$(find "$dir" -type f -exec md5sum {} + | sort | uniq -d -w32) - -echo "Duplicates found:" - -echo "$duplicates" | while read line -do - files=$(grep "$line" <<< "$duplicates" | awk '{print $2}') - for file in ${files[@]} - do - echo "File: $file" - echo "Duplicate(s) of this file:" - for duplicate in ${files[@]} - do - if [ $duplicate != $file ] - then - echo $duplicate - fi - done - echo "Do you want to delete this file? [y/N]" - read answer - if [[ $answer == [yY] || $answer == [yY][eE][sS] ]] - then - rm -i "$file" - fi - done -done