Several ways:
# gather the password into $P stty -echo; read P; stty echo; for i in *.gpg; do echo -- "$i" >> ~/t; printf '%s' | gpg -d --batch --passphrase-fd 0 $i >> ~/t; done # gather the password into $P stty -echo; read P; stty echo; for i in *.gpg; do echo -- "$i" >> ~/t; gpg -d --batch --passphrase "$P" $i >> ~/t; done d=$(mktemp -d) # gather the password into a file named `p` stty -echo; cat > "$d/p"; stty echo for i in *.gpg; do echo -- "$i" >> ~/t; gpg -d --batch --passphrase-file "$d/p" 0 $i >> ~/t; done rm -rf "$d" # gather the password into $P stty -echo; read -r P; stty echo; for i in *.gpg; do printf '%s\n' "$i" >> ~/t; printf '%s' | gpg -d --batch --passphrase-fd 0 "$i" >> ~/t; done # gather the password into $P stty -echo; read -r P; stty echo; for i in *.gpg; do printf '%s\n' "$i" >> ~/t; gpg -d --batch --passphrase "$P" "$i" >> ~/t; done d=$(mktemp -d) # gather the password into a file named `p` stty -echo; cat > "$d/p"; stty echo for i in *.gpg; do printf '%s\n' "$i" >> ~/t; gpg -d --batch --passphrase-file "$d/p" 0 "$i" >> ~/t; done rm -rf "$d"