How to change multiple file type associations on the Mac at once? I want to change my default media player in macOS.

(In my case, I want to change it to my own AppleScript-created instance of VLC that I exported as ‘VLC-New-Window.app’, which is scripted to always open files in a new VLC instance so that it doesn’t override the existing paused playlist or video file I want to keep in the background.)

It is very tedious to find an example of every file type I use VLC for (whether mkv, avi, mp4, m4v, m4a, m4b, mp3, flac, or m2ts), right-click on it, and manually set the new default program each time.

And honestly I’d like every audio or video file type that VLC can open to be applied here so that I never have to worry about this again.

Is there any method that can help automate this, or do this in batch?
Step 1: Put the list of file types (from one of the categories below) into a text file at ~/types.txt, with one per line as shown.
Below are very exhaustive lists for three common media file categories.
Audio:
.2sf
.3ga
.a52
.aa
.aa3
.aac
.aax
.abc
.ac3
.acd
.acm
.act
.adg
.adts
.afc
.ahx
.aif
.aifc
.aiff
.al
.alac
.amb
.amr
.amz
.aob
.apc
.ape
.apf
.apl
.atrac
.au
.avr
.awb
.bap
.bmw
.bwf
.caf
.cda
.cfa
.cidb
.cm3
.cmc
.cmr
.cms
.copy
.cpr
.cwp
.dac
.dcf
.dcm
.dct
.dfc
.dff
.dig
.dlt
.dmc
.dsd
.dsdiff
.dsf
.dss
.dst
.dts
.dtshd
.dtswav
.dvf
.efa
.efe
.efk
.efv
.emd
.emx
.f64
.fc
.fl
.flac
.flp
.fst
.g726
.gnt
.gpx
.gsf
.gsm
.hma
.hmi
.hmp
.htk
.htw
.hvl
.iff
.iklax
.imw
.imy
.its
.ivc
.k26
.kar
.kdm
.kfn
.koe
.koz
.kpl
.ktp
.latm
.lds
.lha
.loas
.lqt
.lvp
.m3u
.m3u8
.m4a
.m4b
.m4p
.m4r
.ma1
.mat
.mdat
.mds
.mid
.midi
.mids
.mini2sf
.minidsf
.minigsf
.minincsf
.miniqsf
.minissf
.miniusf
.mio
.mka
.mlp
.mmf
.mon
.mp2
.mp3
.mp+
.mp_
.mpa
.mpc
.mpd
.mpp
.mpt
.mpu
.msv
.mt2
.mte
.mtp
.mup
.mus
.mxp4
.mzp
.ncor
.ncsf
.nki
.nrt
.nsa
.ntn
.nwc
.odm
.oga
.ogg
.oma
.omg
.omx
.opus
.ots
.ove
.paf
.pcast
.pcm
.pek
.pfv
.pla
.pls
.pna
.prog
.pvc
.qcp
.qsf
.r1m
.ra
.rax
.rex
.rf64
.rfl
.rif
.rmi
.rmj
.rmt
.rns
.rsd
.rso
.rti
.rx2
.sa1
.sap
.sbr
.sd2
.sds
.sf
.sfa
.sgt
.sid
.smf
.snd
.sng
.sns
.sprg
.spx
.sseq
.ssf
.ssnd
.str
.swa
.syh
.sz
.tac
.tap
.tfm
.tfmx
.tfx
.tm2
.tm8
.tmc
.trm
.tta
.ul
.usf
.usflib
.vag
.vmo
.voc
.voi
.vox
.vpm
.vrf
.vy1
.vyf
.w01
.w64
.wav
.wma
.wrk
.wus
.wut
.wv
.wve
.wwu
.xa
.xfs
.xhe
.xi
.xmi
.zgr
.zvr

Video:
.3g2
.3gp
.3mm
.3p2
.60d
.264
.aaf
.aec
.aep
.aepx
.ajp
.am4
.amv
.arf
.arv
.asd
.asf
.asx
.avb
.avd
.avi
.avp
.avs
.ax
.axm
.bdmv
.bik
.bix
.box
.bpj
.bup
.camrec
.cine
.cpi
.cvc
.d2v
.d3v
.dav
.dce
.ddat
.divx
.dkd
.dlx
.dm_84
.dmb
.dpg
.dream
.dsm
.dv
.dv2
.dvm
.dvr
.dvx
.dxr
.edl
.evo
.f4v
.fbr
.fbz
.fcp
.flc
.fli
.flv
.gts
.gvi
.gvp
.h3r
.hdmov
.ifo
.ircp
.irf
.ivr
.ivs
.izz
.izzy
.m1pg
.m2p
.m2t
.m2ts
.m2v
.m4e
.m4u
.m4v
.m21
.mbf
.mbt
.mbv
.mj2
.mjp
.mk3d
.mkv
.mnv
.mocha
.mod
.moff
.moi
.mov
.mp4
.mp4v
.mp21
.mpeg
.mpg
.mpg2
.mqv
.msdvd
.mswmm
.mts
.mtv
.mvb
.mvp
.mxf
.mzt
.nsc
.nsv
.nut
.ogm
.ogv
.ogx
.pds
.pgi
.piv
.plb
.pmf
.pns
.ppj
.prtl
.psh
.pvr
.pxv
.qt
.qtl
.r3d
.ram
.ratdvd
.rm
.rmbv
.rms
.rmvb
.roq
.rpf
.rpl
.rum
.rv
.sdv
.sfvidcap
.slc
.smk
.spl
.sqz
.sub
.svi
.swf
.tda3mt
.thm
.tivo
.tod
.tp0
.trp
.ts
.ty
.udp
.usm
.vcr
.veg
.vft
.vgz
.vid
.viewlet
.vlab
.vmb
.vob
.vp6
.vp7
.vro
.vsp
.vvf
.wd1
.webm
.wlmp
.wmmp
.wmv
.wmx
.wp3
.wtv
.xfl
.xvid
.zm1
.zm2
.zm3
.zmv

(For the few file extensions that I'm aware can apply to either video or audio, e.g. .ram, .mp4, .3gp, .3g2, I've put such an extension into the video list).
Image:
.006
.007
.1ff
.1im
.3dmf
.3dx
.7tif
.8pbs
.abm
.abr
.adi
.aex
.ai
.ais
.ait
.albm
.amu
.apng
.ard
.art
.arw
.asat
.avif
.b16
.bil
.bitmap
.bld
.blend
.blkrt
.blp
.blz
.bmc
.bmp
.bob
.bpg
.br4
.br5
.bum
.c4
.cadrg
.catpart
.ccx
.cdr
.cdt
.cdx
.cel
.cgm
.cht
.clp
.cm2
.cmx
.cmz
.comicdoc
.cpl
.cps
.cpt
.cr2
.csf
.cur
.cv5
.cvg
.cvi
.cvx
.dae
.dcim
.dcm
.dcr
.dcs
.dds
.design
.dib
.dng
.drg
.drw
.drwdot
.dt2
.dvl
.dwb
.dwf
.dxb
.easm
.ebm
.ec3
.edp
.edrw
.edw
.emf
.eprt
.eps
.epsf
.epsi
.exr
.fac
.face
.fbm
.fbx
.fc2
.fcz
.fd2
.fh11
.fhd
.fit
.flic
.flm
.fm
.fpf
.fs
.fw
.fxg
.gcimgd
.gif
.graffle
.gtx
.hd2
.hdz
.heic
.heif
.hpd
.hpi
.hr
.hr2
.htz4
.ibl
.icl
.icns
.ico
.icon
.icq
.ics
.idw
.ief
.iff
.iges
.igr
.ilbm
.ilm
.im1
.im24
.im32
.im8
.ima
.image
.ime
.imi
.ims
.ipj
.irf
.iss
.itc2
.ithmb
.j2k
.jfi
.jfif
.jif
.jiff
.jng
.jp2
.jpe
.jpeg
.jpf
.jpg
.jpg2
.jpm
.jps
.jpw
.jpx
.jt
.jwl
.jxl
.jxr
.k25
.kdc
.kodak
.kpg
.lda
.ldm
.let
.logo
.lt2
.ltz
.lva
.lvf
.lwf
.lxf
.mac
.macp
.mbm
.mcs
.mcz
.mdi
.mgs
.mgx
.mic
.mip
.mj2
.mng
.mpf
.mpo
.mtz
.mur
.nav
.ncr
.neu
.nff
.ngg
.njb
.nol
.nrw
.ntc
.nth
.odi
.odif
.ola
.opd
.ora
.ota
.otb
.otc
.otg
.oti
.ovw
.p21
.p2z
.pac
.pal
.pat
.pbm
.pc6
.pc7
.pcc
.pcd
.pct
.pcx
.pdb
.pdn
.pef
.pfm
.pgc
.pgm
.pi2
.pic
.picnc
.pics
.pict
.pictclipping
.pl0
.pl2
.pln
.plt
.pmb
.png
.pol
.pp2
.ppm
.ppsx
.prw
.ps
.psb
.psd
.psf
.psg
.psp
.pspimage
.psq
.pvl
.pwd
.pws
.px
.pxr
.pz2
.pz3
.qtif
.qtl
.qtz
.qxd
.ras
.raw
.rgo565
.ric
.rlc
.rle
.rs
.rsb
.rsrc
.rw2
.sct
.sdk
.sdr
.sec
.set
.sfw
.sgi
.sig
.skp
.sldasm
.slddrw
.sldprt
.snx
.srf
.sst
.sun
.sup
.svg
.svgz
.t2b
.targa
.tcw
.tcx
.tex
.tga
.tif
.tiff
.tjp
.tn
.tpf
.tpx
.trif
.trx
.u3d
.upx
.urt
.utx
.v00
.v3d
.vfs
.vga
.vis
.vpb
.vrl
.vtx
.wb1
.wbc
.wbd
.wbmp
.wbz
.webp
.wgs
.wi
.wmf
.wnk
.x-face
.x_b
.x_t
.xbm
.xcf
.xdw
.xip
.xpm
.xsi
.xwd
.yuv
.zdl
.zif
.zno
.zprf
.zt

(The above lists were collated from sources including dotwhat.net as at 2020.09.30 (audio, video, image), VLC's formats wiki, foobar2000 documentation, my own knowledge, and various programs' save / export file dialogues. From such sources, I removed a few that I deemed unsuitable as they are commonly used in non-media file contexts and may conflict, e.g. .xz was in a dotwhat.net media list, but it's usually an archive format.)
Some extensions may not open in the universal media player / image viewer you want to switch to, but you can fix it on a doesn't-work basis after the switch.
Step 2: Create temporary dummy files of every extension in an above category in your user folder.
Open Terminal.app, and using your txt file above do the following command:
while read -r line ; do mkfile 1b file${line} ; done &lt; types.txt

Step 3: Select all dummy files in Finder at once, then press option+command+I. Under 'Open With', select the program you want to change the default to, make sure to click on 'Change All...' button, confirm, and it is done.