Say I have a list in a file which contains filenames (without spaces):
filename
othername
somethingelse
...
Is there some kind of touch script I can use to create hundreds of files with titles set by a list?
It would also be incredibly helpful if I could fill each file with content upon creation.
Any bashers have any tips: I'm using Ubuntu 10.04
Thanks
Right-click that folder and select Show more options. Click Copy File List to Clipboard on the classic menu. You'll still need to paste the copied list into a text file. Launch Run, type Notepad in the Open box, and click OK.
Windows 10 Microsoft provides a way of creating a new, blank text file using the right-click menu in File Explorer. Open File Explorer and navigate to the folder where you want to create the text file. Right-click in the folder and go to New > Text Document. The text file is given a default name, New Text Document.
Click the first file or folder, and then press and hold the Ctrl key. While holding Ctrl , click each of the other files or folders you want to select.
To simply create the files, assuming that file_full_of_files_names
is a text file with whitespace-delimited filenames:
cat file_full_of_files_names | xargs touch
To actually fill them with content first, from a file called initial_content
:
cat file_full_of_files_names | tr ' \t' '\n\n' | while read filename; do
if test -f "$filename"; then
echo "Skipping \"$filename\", it already exists"
else
cp -i initial_content "$filename"
fi
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With