Simplifying Data Preservation
In an era where data is as precious as any historical artifact, the ability to efficiently archive digital information becomes paramount. This PowerShell script, Archive Folder.ps1, serves as a digital time capsule, allowing users to seamlessly create a comprehensive archive of any specified folder, ensuring that no byte of valuable data is lost in the sands of time.
# Script Name: Archive Folder.ps1 # Author: Wesley Ellis # Date: 2022-07-18 # Description: Creates an archive of the specified folder in PowerShell. # Define the paths for the archive folder and the current folder $archiveFolder = "C:\File_Path\Your_Archive_Folder_Path\Your_Folder_$((Get-Date).ToString('yyyyMMdd'))" $currentFolder = "C:\File_Path\Your_Folder" # Check if a help command is passed if ($args[0] -eq "/?") { Write-Host "This script creates an archive of the specified folder." -ForegroundColor Cyan Write-Host "Usage:" -ForegroundColor Cyan Write-Host " .\ArchiveFolder.ps1 Run the script normally." -ForegroundColor Cyan Write-Host " .\ArchiveFolder.ps1 /? Display this help message." -ForegroundColor Cyan exit } # Create the archive folder if it does not exist if (-not (Test-Path -Path $archiveFolder)) { New-Item -ItemType Directory -Path $archiveFolder | Out-Null Write-Host "Archive Directory Created" -ForegroundColor Green } # Copy the contents of the current folder to the archive folder Copy-Item -Path $currentFolder -Destination $archiveFolder -Recurse -Force Write-Host "Current Folder Copied" -ForegroundColor Green
Utilizing this script is straightforward: simply define your current and archive folder paths within the script, then run it. The script will craft a new archive directory, named with today’s date for easy reference, and duplicate the contents of your chosen folder into this new safe haven, ensuring your data’s longevity.