Suffix, ta bort

From Linuxwiki
Revision as of 17:03, 11 May 2026 by Linadmin (talk | contribs) (2 revisions imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Ta bort suffix

Olika sätt att ta bort suffix (.MOV, .bat osv) från filnamn.

Källa: https://stackoverflow.com/questions/965053/extract-filename-and-extension-in-bash

filename=$(basename -- "$fullfile")
extension="${filename##*.}"
filename="${filename%.*}"

Exempel för att få fram filnamnet utan suffix:

filnamnet är "MVI_9652.MOV"
filename=MVI_9652.MOV
fn="${filename%.*}

Exempel 2: Koda om MOV-filer till annat format

for x in *.MOV; do echo "in: $x out: ${x%.*}"; ffmpeg -i $x -vcodec libx264 -crf 20 ${x%.*}.mp4; done


Kategori: kortfattat