Skip to content

Instantly share code, notes, and snippets.

@halk
Last active September 21, 2019 22:16
Show Gist options
  • Select an option

  • Save halk/2c7368d7aed58026ae6c to your computer and use it in GitHub Desktop.

Select an option

Save halk/2c7368d7aed58026ae6c to your computer and use it in GitHub Desktop.
Change order by creation date
#!/bin/bash
COUNTER=$(($(ls -l | wc -l)-1))
IFS=$'\n' # make new lines the only separator
for f in `ls | sort -n`
do
# for linux: touch -t `date -v-${COUNTER}S '+%Y%m%d%H%M.%S'` $f
SetFile -d `date -v-${COUNTER}S '+%m/%d/%Y %H:%M:%S'` $f # Mac OS X
COUNTER=$((COUNTER-1))
done
@halk
Copy link
Copy Markdown
Author

halk commented Sep 5, 2015

Had to use this to get order into mp3 files for the EasyAcc external speaker which sorts by creation date

@shuq007
Copy link
Copy Markdown

shuq007 commented Sep 21, 2019

touch in linux only changes files modified date/time but wont change the creation date/time as linux do not have the creation date or time concept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment