Created
August 23, 2021 12:25
-
-
Save wilspi/0d961bc34d3f9816a7d8249d1bbc9d79 to your computer and use it in GitHub Desktop.
Rename files by splitting by "-" and reversing the order in a directory
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
dir="$1" | |
for f in "$dir"/*; do | |
#filename="${cat '$f'}" | |
filename=${f:13:10} # string of length 10 from index 13 | |
arrIN=(${filename//-/ }) # split by "-" | |
reversefilename="${arrIN[2]}-${arrIN[1]}-${arrIN[0]}" | |
reversef="journal/2021/${reversefilename}.md" | |
mv $f $reversef | |
#echo $reversefilename | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment