for loop wget directory creation error

As a Ubuntu beginner. I am trying to download links from multiple text files with wget2 in batch. The -P "$f" creates directory name with .txt suffix. Is it possible to ignore .txt for -P "$f". Any modification suggestions.

for f in *.txt;do wget2 -i "$f" -P "$f";done

I think the most elegant way in bash is to use basename:

$(basename "$filename" "$suffix")

Your script becomes:

for f in *.txt;do wget2 -i "$f" -P "$(basename "$f" .txt)";done

source