Wboy Wboy - 8 months ago 38
Bash Question

Invalid filename given bluetooth transfer bash script

being the lazy bum that I am, I've been trying to make a simple bash script to transfer files from com to my phone. However, when I run the following script, i keep getting "invalid filename given"

for f in *.mp3
bluetooth-sendto --device=<ADDRESS> ${f}

Anyone can point me in the right direction? :)


One of your files properly contains spaces. When you don't quote parameter expansions they will undergo word splitting and globbing. As a rule of thumb you should always quote:

for f in *.mp3; do
  [ -e "$f" ] || continue
  bluetooth-sendto --device=<ADDRESS> "$f"

The reason for [ -e "$f" ] || continue is that if no files is found literal *.mp3 will be in f.