Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save samwolf1982/01a00dcf4735828fc76b46ecfa5be051 to your computer and use it in GitHub Desktop.

Select an option

Save samwolf1982/01a00dcf4735828fc76b46ecfa5be051 to your computer and use it in GitHub Desktop.
renaming all files random name no recursive
#!/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