Skip to content

Instantly share code, notes, and snippets.

@podlom
Created August 18, 2023 12:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save podlom/30ce9f2af87ca1d8013944c31d0edc2f to your computer and use it in GitHub Desktop.
Save podlom/30ce9f2af87ca1d8013944c31d0edc2f to your computer and use it in GitHub Desktop.
Bulk files rename for Ubuntu Linux
#!/bin/bash
# Specify the directory where the files are located
directory="/home/user/Videos/2023-08-18"
# Change to the directory
cd "$directory"
# Iterate over the files matching the pattern and rename them
for file in [0-9]*.mp4; do
new_filename=$(echo "$file" | sed -E "s/^([0-9]+)\.mp4$/_name-prefix-\1.mp4/")
mv -v "$file" "$new_filename"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment