Support
Forums

Re: Changing date format in filenames in Linux

Mike,
I've emailed the two files and show the script here also (ought to have done that at the start!).
[code]#!/bin/bash
#name-reformat.

#Check mp3 files exist. If none then exit:
if [[ -z $(ls *.mp3) ]]; then
  echo "No mp3 files."
  exit
fi

#For each file extract the various parts of the file name.
for file in $(ls -1 *.mp3); do
 day=$(echo $file | cut -d "-" -f 1)
 month=$(echo $file | cut -d "-" -f 2)
 year=$(echo $file | cut -d "-" -f 3 | cut -d "." -f 1)
 suffix=$(e...
Mike,
I've emailed the two files and show the script here also (ought to have done that at the start!).
[code]#!/bin/bash
#name-reformat.

#Check mp3 files exist. If none then exit:
if [[ -z $(ls *.mp3) ]]; then
  echo "No mp3 files."
  exit
fi

#For each file extract the various parts of the file name.
for file in $(ls -1 *.mp3); do
 day=$(echo $file | cut -d "-" -f 1)
 month=$(echo $file | cut -d "-" -f 2)
 year=$(echo $file | cut -d "-" -f 3 | cut -d "." -f 1)
 suffix=$(e...