Skip to main content

Thread: Use info from file name to rename file


i've huge amount of file named a2012178.1220.051.2012178233531.hdf there, 2nd character 8th date, year plus julian day. 13rd character extention of file name rubbish me... rename files , convert date (for convenience).
so far i'm able convert date in bash
code:
converted=$(date -d "${year}-01-01 +${julianday} days -1 day" "+%y%m%d")

but have no idea of how read year , julian day file name , replace name within bash script....
any idea?

code:
file='a2012178.1220.051.2012178233531.hdf' year="${file:1:4}" tail="${file:5}" jday="${tail%%.*}"
btw, last 6 digits before extension time:
code:
$ echo ${file: -10:6} 233531


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help Use info from file name to rename file


Ubuntu

Comments

Popular posts from this blog

Some mp4 files not displaying correctly (CS6)

Thread: Samba is not authenticating with LDAP