0

This is what parameter substitution would be one by one (transforming a picture file name into a date) :

var=“2020-12-30 11-30-55CX.mov”
p1=${var:0:11}
pt=${var:11:8}
p2=${pt//-/:}
dt=“${p1} ${p2}”

I want to do this in one shot, something like this so exiftool can take it:

dt=“${var:0:11} ${${var:11:8}//-/:}”
StarGeek
  • 4,948
  • 2
  • 19
  • 30
Guasqueño
  • 405
  • 9
  • 20

2 Answers2

1

You can't nest expansion operators like that. But you can just work with smaller substrings to get the result you want.

dt="${var:0:11} ${var:11:2}:${var:14:2}:${17:2}"
Barmar
  • 741,623
  • 53
  • 500
  • 612
0

Thanks Barmar for your answer.

I just want to clarify that in the end, as I needed the date-time to be used for the ExifTool, I did not need to do any prior Linux variable substitution as ExifTool had a way to specify whatever date-time format is used in the file name to extract it by using the -d option. So this is what I ended up doing. Note that I didn't even have to remove the ending CX.mov character for ExifTool to get the date-time right:

exiftool -d '%Y-%m-%d $H-%M-%S' \
    '-DateTimeOriginal<${FileName}' \
    '-CreateDate<${FileName}' \
    '-MediaCreateDate<${FileName}' "${file}"
Guasqueño
  • 405
  • 9
  • 20