Created
March 8, 2025 06:36
-
-
Save samwolf1982/01a00dcf4735828fc76b46ecfa5be051 to your computer and use it in GitHub Desktop.
renaming all files random name no recursive
This file contains hidden or 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 | |
| cd /home/sam/Pictures/own_wallpapers/List_dynamic_wallpapers_v2 || exit | |
| for file in *; do | |
| ext="${file##*.}" # Отримуємо розширення | |
| new_name=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 10) # Генеруємо випадковий рядок (10 символів) | |
| if [[ "$file" == *.* ]]; then | |
| mv "$file" "${new_name}.${ext}" # Додаємо крапку перед розширенням | |
| else | |
| mv "$file" "${new_name}" # Якщо немає розширення, просто унікальне ім'я | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment