Created
October 18, 2024 05:11
-
-
Save dewomser/22eff6905806808f97a29c7af4d63052 to your computer and use it in GitHub Desktop.
Ordner Aufräumen. Unterordner anlegen mit kategorie . Nicht von mir aber nützlich.
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
#!/bin/bash | |
# Funktion zur Bestimmung der Kategorie einer Datei | |
get_category() { | |
case "$1" in | |
pdf|docx|txt|doc|odt|rtf) | |
echo "Dokumente" | |
;; | |
png|jpg|jpeg|gif|bmp|tiff) | |
echo "Bilder" | |
;; | |
mp4|avi|mkv|mov|wmv) | |
echo "Videos" | |
;; | |
mp3|wav|flac|ogg|aac) | |
echo "Audio" | |
;; | |
zip|rar|tar|gz|7z) | |
echo "Archive" | |
;; | |
*) | |
echo "Sonstige" | |
;; | |
esac | |
} | |
# Hauptscript | |
for file in *; do | |
if [ -f "$file" ]; then | |
ext="${file##*.}" | |
category=$(get_category "$ext") | |
mkdir -p "$category" | |
mv "$file" "$category/" | |
echo "Verschoben: $file nach $category/" | |
fi | |
done | |
echo "Sortierung abgeschlossen." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment