Created
October 11, 2015 10:20
-
-
Save Phlow/6c05ce9681e91a7be3fb to your computer and use it in GitHub Desktop.
Rename files and use their date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copy MP3 files in a directory to a new name based solely on creation date | |
# FROM: foo.mp3 Created on: 2012-04-18 18:51:44 | |
# TO: 20120418_185144.mp3 | |
for i in *.mp3 | |
do | |
# mod_date=$(stat -c "%y" "$i"|sed 's/\..*$//') | |
# mod_date=$(stat -c "%y" "$i"|awk '{print $1"_"$2}'|sed 's/\..*$//') | |
mod_date=$(stat --format %y "$i"|awk '{print $1"_"$2}'|cut -f1 -d'.'|sed 's/[: -]//g') | |
cp "$i" "$mod_date".mp3 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment