Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Move-Item : There is not enough space on the disk

Tags:

powershell

I need to move files from one directory to another on the same hard drive using PowerShell. The hard drive that I need to do that on is almost always on the limit of the space. My problem is when I try to use the cmdlet Move-Item, I get the error message "There is not enough space on the disk.". However, When using Ctrl+X and Ctrl+V on Windows Explorer it works fine. If I free up space on the hard drive, I'm also able to use the command Move-Item.

So, I was wondering if someone can guide to find a solution to "cut" and " paste" a file using PowerShell that would not need more space on the disk to execute the command?

Get-ChildItem -Path "\\10.72.100.203\Pending\$ticket*" -Recurse -Force |
    Move-Item -Destination "\\10.72.100.203\Completed"

Result:

Move-Item : There is not enough space on the disk.
At C:\script\test2.ps1:66 char:76
+ ... e -Force  | Move-Item -Destination "\\10.72.100.203\Completed" -Force ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (\\10.72.100.203...Mark 0718-3.VHD:FileInfo) [Move-Item],
    + FullyQualifiedErrorId : MoveFileInfoItemIOError,Microsoft.PowerShell.Commands.MoveItemCommand
Powershell version:
PS C:\script> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.15063.502
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.502
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
like image 478
FlCo Avatar asked Aug 21 '17 21:08

FlCo


People also ask

How do I fix there is not enough space available on my disk?

Free up space with Disk Cleanup If your system doesn't have Storage Sense, you can use the Disk Cleanup tool to delete temporary files and system files from your device. In the search box on the taskbar, type disk cleanup, then select it from the results. Select the drive you want to clean up files for, then select OK.

Why does my computer say there is not enough disk space when there is?

Your PC showing Not enough disk space but there is plenty may be due to the following reasons: Insufficient Space for the Specified Operation on your device. Disk Management Error. MBR Partition Limit reached.


1 Answers

There are many ways to go about this but the question is how much space do you have left for the larger files in that folder. Sort your results showing largest first and see if you have enough room for a copy of two of the largest files. You might be running out of room there. You might not have enough room to copy the largest files. If you do then try encapsulating the move command after the pipe in a foreach. Maybe directly piping it is making it try and move all the files first before deleting them.

...| foreach{Move-Item $_ -Destination "your destination folder"}

If you do not have the room then do you have enough ram for the largest file. If so then you will need to get fancy by in a foreach loop for each file you will need to save the file name to a variable (and replace path with relative path to destination if you have subfolders in that old folder path). For each file you will need to read it in as encoding "byte". You then delete the original (hope you have backups). Now write with encoding "byte" the file to the destination with file name.

What you are doing here is using your memory to hold the file while you remove the original to make space and then write it back to the new location.

Personally, I think I would use space on another system to temporarily move the file there to hold while the original is deleted and then move it to where it is supposed to go. If you are that tight on space, I would look at storing those elsewhere until more space can be acquired.

like image 143
Parrish Avatar answered Oct 05 '22 02:10

Parrish