How can I create a file in each folder?
Assuming you have a list of your project directories in a file called "projects.txt", you can do this (for bash and zsh)
for i in $(cat projects.txt)
do
touch $i/index.html
done
To create your projects.txt, you can use the find
command. You could replace the cat
directly with a find
invocation but I thought it more clear to separate the two operations.
cd /project_dir && find . -type d -exec touch \{\}/index.htm \;
HTH
find . -type d -exec touch {}/index.html \;
This'll create an index.html
in .
and all subdirectories.
I know it's an old question but none of the current answers allow to add some sample code, here my solution:
#create a temp file
echo "<?php // Silence is golden" > /tmp/index.php
#for each directory copy the file
find /mydir -type d -exec cp /tmp/index.php {} \;
#Alternative : for each directory copy the file where the file is not already present
find /mydir -type d \! -exec test -e '{}/index.php' \; -exec cp /tmp/index.php {} \;