In this article, Let me show you how to move files from one location to another location using PowerShell script. The Move-Itemย cmdlet moves an item, including its properties, contents, and child items, from one location to another location. The locations must be supported by the same provider.

Move-Item : Cannot create a file when that file already exists.

Example:1 Moving single files/folders

In the PowerShell window, type the command below and press ENTER. After the โ€“path parameter, type the path of the file on your local PC that you want to copy, and after the โ€“destination parameter, type the path of the destination folder. In the example below, Iโ€™m moving a file called URL_List.txt from the Source File Path folder to the Destination File Path folder.

OR we can directly mention the path of files location without -path Keyword

Example:2 Moving all the item which created today.

From below code, we getting all files and folder which created today and move from “Source File Path” folder to “Destination File Path” folder.

Also, by default, Get-ChildItem does not move hidden files. To move hidden files, use theย Forceย parameter withย Get-ChildItem.

Example:3 Moving the files based on File Type (extension)

I had created $_FileType array which contains the list of file types that need to move. After execution, all .html and .txt files will move from source to destination folder. Please refer to the snapshots to under stand the before and after the script execution

OUTPUT:

Before Execution: Source Folder/Destination Folder

After Execution: Source Folder/Destination Folder

 

What do you think?

I hope you have an idea of how to move the files from one location to another location using the Powershell script. I would like to have feedback from the readers of my posts. Your valuable feedback, question, or comments about this article are always welcome.