Global Feed Post Login
Replying to Avatar This is the Breath :verified:

dudes named ben i need some help passing filenames with spaces in bash

command is:

for file in *.flac; do ffmpeg -i $file -q:a 0 ${file%flac}.mp3; done

it chokes on files with spaces

Avatar
Mark :verified: 2y ago

nostr:npub18k0q9esq0e6r8r8yhu7jxvxzp6gpvjp3wp47zl8dzqec6q4nr07qzjwcjh

Yeah - a few methods described in this page using the find command

https://www.baeldung.com/linux/iterate-files-with-spaces-in-names

This page suggests defining $IFS (as well as a few other methods)

https://www.cyberciti.biz/tips/handling-filenames-with-spaces-in-bash.html

Plenty of options available.

Reply to this note

Please Login to reply.

Discussion

No replies yet.