Bash for in folder all files command

Execute Command on All Files in Folder with Bash for in

A memo about how to execute the same command on all files in a folder and loop using a for in statement in the Bash language on the Linux command line. Use the for in syntax.

Shou Arisaka
1 min read
Nov 8, 2025

A memo about how to execute the same command on all files in a folder and loop using a for in statement in the Bash language on the Linux command line.

Use the for in syntax:

for f in *; do  ffprobe -loglevel error -show_entries format_tags=artist -of default=noprint_wrappers=1:nokey=1 "$f" ; done

or

for f in *; do
  ffprobe -loglevel error -show_entries format_tags=artist -of default=noprint_wrappers=1:nokey=1 "$f"
done

$f becomes the file name, but an easy-to-miss point is to enclose it with double quotes like "$f".

Reference:

bash command for each file in a folder - Ask Ubuntu

Share this article

Shou Arisaka Nov 8, 2025

๐Ÿ”— Copy Links