File: Screenshot from 2026-05-06 16-55-29.png (106.3 KB)
I have a audio player that sorts files by creation / modification date, so i need the creation date to match the track number for the album to play in proper order. Pic rel is one folder where the date is the same on every file, but i need some some kind of program that can modify these so file 01 has the earliest date and then it grows with every with every next file. I'm using Linux mInt
Showing all 8 replies.
>>
>>
>>
>>
>>
>>
#!/bin/bash
# fix_track_timestamps.sh
# Sets file modification/access times so files sort in filename order.
# Each file gets a timestamp 1 minute apart, starting from a base date.
#
# Usage:
# ./fix_track_timestamps.sh /path/to/album/folder
# ./fix_track_timestamps.sh <- uses current directory
TARGET_DIR="${1:-.}"
# Base timestamp: change this if you want a different starting point
BASE_DATE="2000-01-01 00:00:00"
# Audio file extensions to process (add more if needed)
EXTENSIONS="mp3|flac|ogg|wav|aac|m4a|wma|opus|ape|mpc|aiff|alac"
echo "=== Track Timestamp Fixer ==="
echo "Folder : $TARGET_DIR"
echo "Base : $BASE_DATE"
echo ""
# Collect and sort matching files by filename (natural sort handles 01, 02 ... 10, 11 correctly)
mapfile -t FILES < <(find "$TARGET_DIR" -maxdepth 1 -type f \
| grep -iE "\.($EXTENSIONS)$" \
| sort -V)
if [ ${#FILES[@]} -eq 0 ]; then
echo "No audio files found in '$TARGET_DIR'."
exit 1
fi
echo "Found ${#FILES[@]} file(s). Applying timestamps..."
echo ""
# Convert base date to Unix epoch seconds
BASE_EPOCH=$(date -d "$BASE_DATE" +%s)
INTERVAL=60 # seconds between each file (1 minute)
for i in "${!FILES[@]}"; do
FILE="${FILES[$i]}"
BASENAME=$(basename "$FILE")
NEW_EPOCH=$(( BASE_EPOCH + i * INTERVAL ))
NEW_STAMP=$(date -d "@$NEW_EPOCH" +"%Y%m%d%H%M.%S") # format for 'touch'
NEW_HUMAN=$(date -d "@$NEW_EPOCH" +"%Y-%m-%d %H:%M:%S")
# -t sets both access and modification time; no creation time on Linux ext4
touch -t "$NEW_STAMP" "$FILE"
printf " [%02d] %-45s -> %s\n" "$((i+1))" "$BASENAME" "$NEW_HUMAN"
done
echo ""
echo "Done! All timestamps updated."
echo ""
echo "TIP: On Linux, 'creation time' (birth time) is not reliably settable."
echo "Most players sort by *modification* time, which this script updates."
echo "If your player uses birth time, see the notes in the README below."
>>
>>1564568
exiftool
You'll have to look it up because I'm not an expert.
You'll want to use a substring of the first two characters from the filename and write to the CreateDate. If the program sorts by time not just the day date then you can write to the seconds or minutes, and with more files than days per months or seconds per minute you can use a variable to increment the month or minute while decrementing integer value of the filename's first two characters back to 00 or 01