Create Multiple Empty Files Using PowerShell

This blog post will show how to use PowerShell to create multiple empty files on an operating system (Linux or Windows).

To create multiple files, I am using a text file with a list of the file names I would like to create. In this example, the files text file is called Files.txt as shown below.

Files.TXT

The text file can contain the name of the files, you would like to create. List them one after another as shown below.

file1.txt
file2.txt
file3.txt

PowerShell

To create the files, I am reading the file line by line and creating each file. The cmdlet is using a foreach-object loop and creates each file.

get-content files.txt | foreach-object {new-item $_}

As shown in this post, using PowerShell to automate everyday tasks is handy and saves time.

About PowerShell

PowerShell is a powerful scripting language that can be used to automate a wide variety of tasks. It can be used on Windows systems, and there is also a popular PowerShell Core version that can be used on Linux and Mac systems. PowerShell provides a comprehensive set of features that makes it an ideal tool for automating tasks. It can be used to manage files and folders, query system information, run commands on remote systems, and much more. PowerShell is also well-supported with a large community of users who are always willing to help. If you’re looking for a powerful and versatile scripting language, PowerShell is definitely worth considering.

1 comment

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.