How to copy, delete, move, rename files/folders using PowerShell on Windows PC
Although simpler and quicker methods exist - such as using a GUI - using PowerShell has its own benefits.
For example, with PowerShell, you can automate many of your tasks by writing scripts, manage other computers remotely, and have more administrative control than you would otherwise. So, if you're someone who likes to have more control over your work, then using PowerShell is the obvious choice.
Let's go through all the individual commands, starting with copying.
How to copy files or folders using PowerShell
PowerShell is an all-in-one utility for Windows administrators and enthusiasts alike. You can easily copy your files or folders using PowerShell. To get started, first launch PowerShell, then use the copy-item command to copy your files from PowerShell. Here's how:
- Go to the search bar in the Start menu, type 'powershell' and press Enter.
- Now, use the 'Set-Location' cmdlet to change the directory of your files. For example, to go to the Downloads folder on your computer, enter the following command and press Enter :
Set-Location -Path "C:Users[Username]Downloads"
- Once you are in the correct path, enter the following command and press Enter:
Copy-Item -Path "text1.txt" -Destination "C:DestinationFolder"
Replace text1.txt with the path of the file you want to copy and replace C:DestinationFolder with the path of the folder you want to paste your copied files into. Enter the command and your files will be instantly copied from one place to another.
You can check if your files were copied successfully by using the DIR cmdlet to list the files in the specified directory.
How to copy folders using PowerShell
In the case of directories, you just need to slightly adjust the last command. This is the way:
Copy-Item -Path ".exampleFolder" -Destination 'C:DestinationFolder" ~Recurse
PowerShell will copy the selected folder and its contents.
How to move files or folders using PowerShell
Similar to copying, you can use a simple command to move your files or folders on PowerShell. Here's how:
Once you have launched PowerShell, enter the following command and press Enter :
Move-Item -Path "filename.txt" -Destination "C:DestinationFolder"
Again, replace filename.txt with the full path of the file and DestinationFolder with the path of the folder you want to move your files to.
After that, you can check if your file has been moved using the DIR command. If you don't see your file in the old folder, you can rest assured that the file has been moved to the specified destination.
To move multiple files at once, use the following command and press Enter :
Move-Item -Path "file1.txt", "file2.txt" -Destination "C:DestinationFolder"
How to move folders using PowerShell
Again, similar to the copy command above, you can also move folders. Here is the command to execute:
Move-Item -Path "FolderName" -Destination "C:DestinationFolder"
How to delete files or folders using PowerShell
Follow the steps below and you will be able to delete your files or folders using PowerShell in no time:
- Enter cmdlet Remove-Item followed by the file path and press Enter :
Remove-Item -Path "filename.txt"
- Now, replace "filename.txt" with the name of the file you want to delete.
To delete multiple files, adjust the cmdlet by adding different file names to the path parameters (separated by commas) and pressing Enter :
Remove-Item -Path "file1.txt", "file2.txt", "file3.txt"
How to delete folders using PowerShell
Once you have launched PowerShell, enter the Remove-Item cmdlet, along with the Recurse parameter , and press Enter :
Remove-Item -Path "Folder" -Recurse
Replace "Folder" with the path of the folder you want to delete. In general, when you are trying to delete a file or folder, you will receive a confirmation prompt. You can bypass this prompt and delete your files immediately by adding the -Force parameter at the end of the command.
Rename files using PowerShell
Again, right-clicking on the file in question, then selecting Rename works best in most cases, but not always. In cases where there are problems, PowerShell can help.
After you have launched PowerShell, enter the following command to rename your file and press Enter :
Rename-Item -Path "C:pathtooldfilename.txt" -NewName "newfilename.txt"
Rename folders using PowerShell
To rename a folder, use the same Rename-Item cmdlet; Type it into PowerShell and press Enter :
Rename-Item -Path "C:Downloadsoldfoldername" -NewName "newfoldername"
You should read it
- What is PowerShell Basic commands in PowerShell
- Use PowerShell to download any file on Windows 10
- PowerShell command in Windows
- How to use PowerShell's default parameter to change the command behavior
- How to check PowerShell version in Windows 10
- Instructions on how to use PowerShell in Windows Server 2012
- What is Windows PowerShell? How to use Windows PowerShell
- What to do when Windows can't find PowerShell?
May be interested
- What to do when Windows can't find PowerShell?powershell is a handy tool that allows you to automate tasks, fix various errors, and manage several windows installations. but what if it suddenly disappears from your computer?
- Use PowerShell to download any file on Windows 10windows powershell is a tool built into windows 10. this tool has the ability to set up more features than command prompt, better operating system control .... most likely, powershell will replace command prompt in the future.
- PowerShell command in Windowswindows powershell is an executable command line and a scripting language specifically designed for system administrators.
- Search and delete empty folders on Windows using PowerShellhow to search and delete empty folders on windows operating system? trick to use windows powershell to find and delete empty folders on windows 10
- How to connect to an FTP Server from Windows Explorer?windows allows users to easily connect to an ftp server and the shared ftp folder using add network location wizard. after running the wizard, you can easily manage (copy, move, delete, create or rename ...) all content on ftp server from windows explorer.
- How to Install or Update PowerShell on Windows 11windows powershell is a command line tool developed by microsoft that helps you automate common tasks on your system.
- How to check PowerShell version in Windows 10powershell is one of the extremely useful command tools for advanced windows 10 users.
- 4 Ways to copy files faster in Windowscopy feature in windows 7 is nothing outstanding, it is only temporary, it is not the fastest when you proceed to copy and move one or more large files. however, there are several ways to help you quickly copy files efficiently in windows.
- How to Move the Copy Folder in Windowswhen the copy desktop application was first installed in your computer, it created its own local folder named copy under my documents. this is where the files from your copy account are placed and synced. if, for whatever reason, you...
- Add Copy to folder and Move to folder in the right-click menuthe following tips will help you add copy to folder and move to folder options to context menu (context menu or right-click menu) on windows. with these two options, you can easily copy or move one or more files / folders to another location without having to use copy / paste or cut / pase operations ( cut and paste).