Thursday, July 14, 2016

Renaming files to crtime on Ext4

 ## Dates are of a format: FILE_20160612.txt yet the date portion is wrong 
 ## it should reflect the creation date of the file. The creation date needs 
 ## to be grabbed from Ext4 (pre-xstat) and the file moved to the proper file
 ## name. See the next blog entry for lscrtime. 
while read a; do 
 fcrdt=$(lscrtime "${a}" | date -d"$(awk '$1="";1')" +%Y%m%d)
 fprefix="$(sed 's/_.*$//' <<< "$a")"
 mv "${a}" "${fprefix}_${fcrdt}.txt"
done < <(find . -type f) 

No comments:

Post a Comment