Hi Everyone!
I’m looking for a way to create multiple text files from words list i.e,
A list like:
- Cats
- Dogs
- Rabbits
- Etc.
In to:
- Cats.txt
- Dogs.txt
- Rabbits.txt
- Etc.txt
Is there any easy way to do so?
Hi Everyone!
I’m looking for a way to create multiple text files from words list i.e,
A list like:
In to:
Is there any easy way to do so?
Using python, Yes.
Save this snippet in a file
li=['cat','dog','lion']
for i in li:
open(i+'.txt','a').close()
print('Creating {}.txt'.format(i))
Change the names in the list ‘li’ and run the program.
Text files will be created in the same directory.
In Bash, you can do this…
name=("apple" "cow" "banana")
for i in "${name[@]}"
do
touch $i.txt
done
Many Thanks, It just work like a charm.
Many Thanks Mahesh, It’s working solution as well.