Copy Project’s Folder structure without content using Powershell

#windows10 #PowerShell

You were working on a Project and created a nice structure in Windows. All Project activity is nicely organised in different folders and files are stored in the required folders.

Now you are going to start a new Project and you want to use the same folder structure but don’t want all the content stored under each folder.

One way is to copy the complete project and then go to each folder and delete the entries one by one. I know you don’t want to do this and that’s why you are reading this post.

Let me tell you the better way doing it and it will save you a lot of time. Now You can start your new Project with the same template you made for your previous project

PowerShell

#PowerShell


We will be using PowerShell to accomplish that task. Windows 10 comes with a nice scripting tool called PowerShell. It is a great tool to automate your tasks in Windows. PowerShell is quite powerful and can do a lot more what we want to do now. For our task you really don’t need to have deep knowledge of PowerShell. Just follow the instructions and you are good to go. If you want to learn more about PowerShell, follow the link below

PowerShell Documentation

click here

Delete all files but keep the folder structure intact

Before we start deleting the files, I assume you have copied the Project to a new location. Make sure you are not doing it on an original project files.

If you also want to use PowerShell to copy your project to a new location. Please check out my post “Copy Files and Folders using PowerShell”

https://platform.twitter.com/widgets.js

Now you have copied the Project Folders to a new location and you want to delete the contents i.e Files So that you can start with a new project.

Start PowerShell

  • Go to start menu and type PowerShell.
  • Open PowerShell
  • Type in the below command

PS > Get-ChildItem -Path <PATH> -Include . -File -Recurse | foreach { $_.Delete()}

  • Replace <Path> with the path of the folder you want to the delete the content from
  • The above command will delete the files from the folders and sub directories

Let me know with your feedback guys. Share your experience.

Good Luck

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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