Skip to main content

Thread: Rename output file from script?


below script uses handbrake cli convert videos mp4 container can play across devices.

currently, output ends being very, long because keeps old extension , have have output file add onto it.

code:
#!/bin/bash  # handbrake processing script "convert.sh"    file in /mnt/storage2/videos/convert.pending/*    # 6 channel passthrough only; android devices cannot hardware decode  handbrakecli -i "$file" -o "$file".hb.mp4 -f mp4 -4 -o --strict-anamorphic -m -e x264 -q 19 -a 1 -e copy:ac3 -6 6ch -b 640 --verbose=1    #move original  mv $file /mnt/storage2/converting/processed/    #move new  mv $file.hb.mp4 /mnt/storage2/videos/movies/
how can modify basic script take $file injected , output less full $full?

i'd take first part before "." extension, keep it, , use in output plus new extension.

input appreciated!

you can use bash % , %% parameter substitutions remove shortest matching suffix or longest matching suffix respectively

code:
file="long file.with.lots.of.extensions"; echo "${file%.*}" long file.with.lots.of
code:
$ file="long file.with.lots.of.extensions"; echo "${file%%.*}" long file
to grab *just* extension can use corresponding # or ## snip shortest or longest prefix

code:
$ file="long file.with.lots.of.extensions"; echo "${file##*.}" extensions
hope helps


Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [ubuntu] Rename output file from script?


Ubuntu

Comments

Popular posts from this blog

Could not place because the source rectangle is empty

Thread: Using smartcard reader with vpnc

Adobe Font Folio 7.0 or just 7?