INTRODUCTION

If you want to copy a file to a new directory using Powershell, you can’t just run the regular Copy-Item command:

Copy-Item "file.txt" -Destination "C:\Newfolder\file.txt" -Force
If you do, you will get this error:

Copy-Item: Could not find a part of the path ‘C:\NewFolder\file.txt’

Powershell Copy to non-existing folder error

SOLUTION

Instead, you need to create the create the folder before copying the file. Use the below one-liner.

Copy-Item "file.txt" -Destination "C:\Newfolder\file.txt" -Force

RELATED POSTS