Say you have 10,000 files with random names, and you want to rename them all into 1–10000 based on its current alphabetical order.
Step 1
Locate the folder containing the files. Press Alt, right click on the folder, and select “Copy [folder name] as a Pathname”.
Next, open Terminal and enter the command below. Replace the highlighted path with the copied path of the folder, then press Enter.
cd /path/to/your/folder
Step 2
Copy and paste this command, then press Enter.
n=1
for f in *; do
if [ -f "$f" ]; then
ext="${f##*.}"
mv -- "$f" "$n.${ext}"
n=$((n + 1))
fi
done