Robocopy command that copies all files and folders from Folder A to Folder and How to cipher zero fill secure erase
Tags: security, privacy, file, hdd
Published: 2023-11-29 11:29:09

## Copy Files

To create a Robocopy command that copies all files and folders from Folder A to Folder B, overwriting only if the source file is newer, and verifying the copy with a file hash, you would use the following command:

`robocopy “C:\Path\To\FolderA” “D:\Path\To\FolderB” /E /XO /V /ZB`

Here’s what each part of the command does:

"C:\Path\To\FolderA": Replace this with the path to your source folder (Folder A).
"C:\Path\To\FolderB": Replace this with the path to your destination folder (Folder B).
/E: Copies subdirectories, including empty ones.
/XO: Excludes older files - this means it will only overwrite if the file in Folder A is newer.
/V: Produces verbose output, showing skipped files.
/ZB: Uses restartable mode; if access is denied, this switch uses Backup mode.
Robocopy does not have a built-in hash verification for each file. However, it is a reliable tool for file copying and the /V option gives you a detailed output of the operations, which can be useful for verifying the copy process. For hash verification, you would need to use another tool or script to compare the hash values of the files in both folders after the copy process is complete.

For example another command I used to copy D into H into specific folder

`robocopy “D:\\” “H:\backup” /E /XO /V /ZB`

## Cipher Zero Fill Secure Erase

The command `cipher /w:D` is used in Windows operating systems, specifically as part of the command-line interface (CLI). Here's a detailed explanation of its components:

cipher: This is the main command. cipher is a built-in Windows utility used primarily for managing the encryption of NTFS file systems. Encryption is the process of encoding information in such a way that only authorized parties can access it.
/w: This is a switch or option used with the cipher command. The /w switch is used to remove data from available unused disk space on the entire volume. If you're familiar with how file deletion works in Windows, you know that when you delete a file, it's not immediately removed from the disk; only the reference to the file is deleted. The actual data remains on the disk until it's overwritten by new data. The /w switch is used to overwrite this space to prevent any potential recovery of deleted data.
D: This part of the command specifies the drive letter. In this case, D refers to the D: drive on your computer. When you run the command cipher /w:D, it means you are instructing the cipher utility to wipe clean the unused space on the D: drive.
When you execute cipher /w:D, the following occurs:

The command targets the specified drive (D: in this case).
It goes through three passes of writing data to the drive.
In the first pass, it overwrites all the free space with zeros (0x00).
In the second pass, it overwrites the space with ones (0xFF).
In the third and final pass, it overwrites the space with random numbers.
The primary purpose of this operation is to ensure that any previously deleted files cannot be recovered, which is a useful security measure if you’re going to dispose of the drive or transfer it to someone else.

Remember, this command doesn’t affect existing files and folders. It only works on the space that is marked as free and where deleted files might still be recoverable. Also, the process can take a considerable amount of time, depending on the size of the drive and the speed of the computer.