first commit

This commit is contained in:
hOLOlu
2025-11-14 01:21:50 +03:00
commit 8f16d171e0
7 changed files with 352 additions and 0 deletions

118
BackupFolder.ps1 Normal file
View File

@@ -0,0 +1,118 @@
# BackupFolder.ps1
# Script to backup and compress folders from Windows context menu
param(
[Parameter(Mandatory=$true)]
[string]$FolderPath
)
# Function to show message
function Show-Message {
param(
[string]$Message,
[string]$Title = "Klasör Yedekleme",
[int]$Type = 0 # 0=Info, 1=Error, 2=Warning
)
switch ($Type) {
0 { $icon = 64 } # Information
1 { $icon = 16 } # Error
2 { $icon = 48 } # Warning
default { $icon = 64 }
}
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
[System.Windows.Forms.MessageBox]::Show($Message, $Title, 0, $icon) | Out-Null
}
# Check if folder exists
if (-not (Test-Path $FolderPath)) {
Show-Message -Message "Belirtilen klasör mevcut deðil: $FolderPath" -Type 1
exit 1
}
# Get folder name
$FolderName = Split-Path $FolderPath -Leaf
# Get current date in YYYYMMDD format
$Date = Get-Date -Format "yyyyMMdd"
# Determine output directory (same as source folder)
$OutputDir = Split-Path $FolderPath -Parent
# Find existing backups with same name and date to determine next number
$Pattern = "^${FolderName}_${Date}_\d{3}\.(rar|zip)$"
$ExistingBackups = Get-ChildItem -Path $OutputDir -Filter "${FolderName}_${Date}_*" | Where-Object { $_.Name -match $Pattern }
$NextNumber = 1
if ($ExistingBackups) {
$Numbers = $ExistingBackups.Name | ForEach-Object {
if ($_ -match "_([0-9]{3})\.(rar|zip)$") { [int]$matches[1] }
} | Sort-Object
if ($Numbers) {
$NextNumber = ($Numbers | Select-Object -Last 1) + 1
}
}
$NumberFormatted = "{0:D3}" -f $NextNumber
# Try WinRAR first
$WinRarPath = "${env:ProgramFiles}\WinRAR\rar.exe"
$UseWinRar = Test-Path $WinRarPath
# If WinRAR not found, try 7-Zip
$SevenZipPath = "${env:ProgramFiles}\7-Zip\7z.exe"
$UseSevenZip = Test-Path $SevenZipPath
# If neither found, use PowerShell Compress-Archive
$UsePowerShellArchive = -not ($UseWinRar -or $UseSevenZip)
# Create backup filename
if ($UseWinRar) {
$OutputFile = Join-Path $OutputDir "${FolderName}_${Date}_${NumberFormatted}.rar"
} else {
$OutputFile = Join-Path $OutputDir "${FolderName}_${Date}_${NumberFormatted}.zip"
}
try {
if ($UseWinRar) {
# Use WinRAR
# Change to the parent directory and use relative path to avoid full path in archive
Push-Location $OutputDir
try {
$Arguments = "a -r `"$OutputFile`" `".\$FolderName`""
Start-Process -FilePath $WinRarPath -ArgumentList $Arguments -Wait -NoNewWindow
}
finally {
Pop-Location
}
}
elseif ($UseSevenZip) {
# Use 7-Zip
# Change to the parent directory and use relative path to avoid full path in archive
Push-Location $OutputDir
try {
$Arguments = "a `"$OutputFile`" `".\$FolderName`""
Start-Process -FilePath $SevenZipPath -ArgumentList $Arguments -Wait -NoNewWindow
}
finally {
Pop-Location
}
}
else {
# Use PowerShell built-in Compress-Archive
# Fix the path issue by changing to the parent directory and using relative path
Push-Location $OutputDir
try {
Compress-Archive -Path ".\$FolderName" -DestinationPath $OutputFile -Force
}
finally {
Pop-Location
}
}
Show-Message -Message "Yedekleme baþarýyla tamamlandý!`n`nDosya: $OutputFile"
}
catch {
Show-Message -Message "Yedekleme sýrasýnda hata oluþtu:`n$($_.Exception.Message)" -Type 1
}

6
Install.bat Normal file
View File

@@ -0,0 +1,6 @@
@echo off
REM Install.bat
REM Klasör yedekleme sağ tık menüsü entegrasyonunu yüklemek için batch dosyası
powershell.exe -ExecutionPolicy Bypass -File "%~dp0Install.ps1"
pause

57
Install.ps1 Normal file
View File

@@ -0,0 +1,57 @@
# Install.ps1
# Script to install the folder backup context menu integration
# Check for admin rights
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Host "Bu komut dosyasý yönetici ayrýcalýklarý gerektirir. Lütfen Yönetici olarak çalýþtýrýn." -ForegroundColor Red
exit 1
}
# Get the current script directory
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Definition
# Path to the backup script
$BackupScriptPath = Join-Path $ScriptDir "BackupFolder.ps1"
# Check if backup script exists
if (-not (Test-Path $BackupScriptPath)) {
Write-Host "Hata: BackupFolder.ps1 dosyasý $ScriptDir dizininde bulunamadý" -ForegroundColor Red
exit 1
}
Write-Host "Klasör Yedekleme Sað Týk Menüsü Entegrasyonu Kuruluyor..." -ForegroundColor Green
# Define registry paths
$FolderContextMenuPath = "Registry::HKEY_CLASSES_ROOT\Directory\shell\BackupFolder"
$BackgroundContextMenuPath = "Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\BackupFolder"
try {
# Create folder context menu entry
New-Item -Path $FolderContextMenuPath -Force | Out-Null
New-ItemProperty -Path $FolderContextMenuPath -Name "(Default)" -Value "Yedekle ve Sýkýþtýr" -PropertyType String -Force | Out-Null
New-ItemProperty -Path $FolderContextMenuPath -Name "Icon" -Value "powershell.exe" -PropertyType String -Force | Out-Null
# Create command subkey for folder context menu
$FolderCommandPath = "$FolderContextMenuPath\command"
New-Item -Path $FolderCommandPath -Force | Out-Null
$CommandValue = "powershell.exe -ExecutionPolicy Bypass -File `"$BackupScriptPath`" -FolderPath `"%V`""
New-ItemProperty -Path $FolderCommandPath -Name "(Default)" -Value $CommandValue -PropertyType String -Force | Out-Null
# Create background context menu entry
New-Item -Path $BackgroundContextMenuPath -Force | Out-Null
New-ItemProperty -Path $BackgroundContextMenuPath -Name "(Default)" -Value "Yedekle ve Sýkýþtýr" -PropertyType String -Force | Out-Null
New-ItemProperty -Path $BackgroundContextMenuPath -Name "Icon" -Value "powershell.exe" -PropertyType String -Force | Out-Null
# Create command subkey for background context menu
$BackgroundCommandPath = "$BackgroundContextMenuPath\command"
New-Item -Path $BackgroundCommandPath -Force | Out-Null
$BackgroundCommandValue = "powershell.exe -ExecutionPolicy Bypass -File `"$BackupScriptPath`" -FolderPath `"%V`""
New-ItemProperty -Path $BackgroundCommandPath -Name "(Default)" -Value $BackgroundCommandValue -PropertyType String -Force | Out-Null
Write-Host "Kurulum baþarýyla tamamlandý!" -ForegroundColor Green
Write-Host "Artýk klasörler üzerinde veya boþ alanda sað týklayarak yedekleme ve sýkýþtýrma yapabilirsiniz." -ForegroundColor Yellow
}
catch {
Write-Host "Kurulum sýrasýnda hata oluþtu: $($_.Exception.Message)" -ForegroundColor Red
}

90
README.md Normal file
View File

@@ -0,0 +1,90 @@
# Klasör Yedekleme Aracı / Folder Backup Tool
## Türkçe Açıklama
Bu araç, klasörler için Windows sağ tık menüsüne "Yedekle ve Sıkıştır" seçeneği ekler.
### Özellikler
- Klasörler ve boş alan için "Yedekle ve Sıkıştır" seçeneğini sağ tık menüsüne ekler
- Zaman damgalı ve numaralandırılmış yedeklemeleri otomatik olarak oluşturur
- WinRAR, 7-Zip veya PowerShell'in yerleşik sıkıştırma özelliğini destekler
- Türkçe karakterleri doğru şekilde işler
- Aynı gün içinde yapılan çoklu yedeklemeler için otomatik numaralandırma
### Kurulum
1. `Install.bat` dosyasını Yönetici olarak çalıştırın (veya `Install.ps1` dosyasını PowerShell ile)
2. Sağ tık menüsü seçeneği hemen kullanılabilir olacak
### Kullanım
1. Windows Explorer'da herhangi bir klasörün veya boş alanın üzerine sağ tıklayın
2. "Yedekle ve Sıkıştır" seçeneğini seçin
3. Yedekleme, aşağıdaki formatta aynı dizinde oluşturulacak:
`<KlasörAdı>_<YYYYMMDD>_<Numara>.rar` (veya WinRAR mevcut değilse .zip)
### Kaldırma
1. `Uninstall.bat` dosyasını Yönetici olarak çalıştırın (veya `Uninstall.ps1` dosyasını PowerShell ile)
2. Sağ tık menüsü seçeneği kaldırılacak
### Gereksinimler
- Windows 10 veya 11
- PowerShell 5.1 veya sonrası
- İsteğe bağlı: Daha iyi sıkıştırma seçenekleri için WinRAR veya 7-Zip
## English Description
# Folder Backup Tool
This tool adds a "Yedekle ve Sıkıştır" (Backup and Compress) option to the Windows context menu for folders.
## Features
- Adds "Yedekle ve Sıkıştır" option to right-click menu for folders and empty space
- Automatically creates compressed backups with timestamp and numbering
- Supports WinRAR, 7-Zip, or PowerShell's built-in compression
- Handles Turkish characters correctly with ANSI encoding
- Automatic numbering for multiple backups in the same day
- All messages and interface elements are available in both Turkish and English
## Installation
1. Run `Install.bat` as Administrator (or `Install.ps1` with PowerShell)
2. The context menu option will be available immediately
## Usage
1. Right-click on any folder or in empty space in Windows Explorer
2. Select "Yedekle ve Sıkıştır"
3. The backup will be created in the same directory with the format:
`<FolderName>_<YYYYMMDD>_<Number>.rar` (or .zip if WinRAR is not available)
## Uninstallation
1. Run `Uninstall.bat` as Administrator (or `Uninstall.ps1` with PowerShell)
2. The context menu option will be removed
## Requirements
- Windows 10 or 11
- PowerShell 5.1 or later
- Optional: WinRAR or 7-Zip for better compression options
## How It Works
The installer adds registry entries that integrate with Windows Explorer context menus. When selected, it runs the PowerShell script that:
1. Determines the next backup number by scanning existing backups
2. Uses WinRAR, 7-Zip, or PowerShell's Compress-Archive (in order of preference)
3. Creates the backup with the proper naming convention
4. Shows success or error messages in Turkish or English
## Recent Improvements
- Fixed Turkish character display issues in context menu by using ANSI encoding
- Updated all messages and interface elements to support both Turkish and English
- Improved file naming consistency with proper variable expansion
- Enhanced path handling to compress only selected folder content without full directory paths
- Added admin rights checking for installation and uninstallation scripts

6
Uninstall.bat Normal file
View File

@@ -0,0 +1,6 @@
@echo off
REM Uninstall.bat
REM Klasör yedekleme sağ tık menüsü entegrasyonunu kaldırmak için batch dosyası
powershell.exe -ExecutionPolicy Bypass -File "%~dp0Uninstall.ps1"
pause

34
Uninstall.ps1 Normal file
View File

@@ -0,0 +1,34 @@
# Uninstall.ps1
# Script to uninstall the folder backup context menu integration
# Check for admin rights
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Host "Bu komut dosyasý yönetici ayrýcalýklarý gerektirir. Lütfen Yönetici olarak çalýþtýrýn." -ForegroundColor Red
exit 1
}
Write-Host "Klasör Yedekleme Sað Týk Menüsü Entegrasyonu Kaldýrýlýyor..." -ForegroundColor Yellow
# Define registry paths
$FolderContextMenuPath = "Registry::HKEY_CLASSES_ROOT\Directory\shell\BackupFolder"
$BackgroundContextMenuPath = "Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\BackupFolder"
try {
# Remove folder context menu entry
if (Test-Path $FolderContextMenuPath) {
Remove-Item -Path $FolderContextMenuPath -Recurse -Force
Write-Host "Klasör sað týk menüsü girdisi kaldýrýldý" -ForegroundColor Green
}
# Remove background context menu entry
if (Test-Path $BackgroundContextMenuPath) {
Remove-Item -Path $BackgroundContextMenuPath -Recurse -Force
Write-Host "Arka plan sað týk menüsü girdisi kaldýrýldý" -ForegroundColor Green
}
Write-Host "Kaldýrma iþlemi baþarýyla tamamlandý!" -ForegroundColor Green
}
catch {
Write-Host "Kaldýrma iþlemi sýrasýnda hata oluþtu: $($_.Exception.Message)" -ForegroundColor Red
}

41
yapi.md Normal file
View File

@@ -0,0 +1,41 @@
**Görev: Windows Sağ Tık Menüsüne Klasör Yedekleme Özelliği Ekle**
Windows gezgininde bir klasör üzerindeyken sağ tıkladığımda çıkan menüye "Yedekle ve Sıkıştır" seçeneği ekleyen bir çözüm geliştir.
**Gereksinimler:**
1. **Sağ Tık Menüsü Entegrasyonu:**
- Windows Registry'ye uygun kayıtları ekleyerek sağ tık menüsünde "Yedekle ve Sıkıştır" seçeneği oluştur
- Hem klasörler için hem de boş alanda sağ tık yapıldığında çalışmalı
2. **Sıkıştırma İşlemi:**
- Birinci seçenek olarak WinRAR komut satırı (rar.exe) kullan
- İkinci seçenek olarak ücretsiz alternatif: 7-Zip komut satırı (7z.exe) veya PowerShell'in yerleşik Compress-Archive cmdlet'ini kullan
- Sıkıştırma formatı: RAR (WinRAR için) veya ZIP (alternatifler için)
3. **Dosya Adlandırma:**
- Format: `<Klasör_adı>_<tarih>_<no>.rar` (veya .zip)
- Tarih formatı: `YYYYMMDD` (örnek: 20241114)
- Numara: Aynı klasör için aynı gün içinde yapılan sıkıştırmalarda otomatik artan sıra numarası (001, 002, 003...)
- Örnek çıktı: `MusteriDosyalari_20241114_001.rar`
4. **Numara Takibi:**
- Aynı klasör adı ve tarih için mevcut yedekleri tara
- En yüksek numarayı bul ve bir sonrakini kullan
- Yedek dosyası kaynak klasörle aynı dizine kaydedilecek
5. **Hata Yönetimi:**
- WinRAR/7-Zip kurulu değilse kullanıcıyı bilgilendir
- Sıkıştırma başarısız olursa hata mesajı göster
- Yedekleme başarılı olursa bildirim göster
**Çıktı:**
- Gerekli tüm dosyaları içeren çalışır bir çözüm (batch script, PowerShell script veya küçük bir executable)
- Registry değişikliklerini otomatik yapan kurulum scripti
- Kaldırma scripti
- Kullanım talimatları
**Teknik Notlar:**
- Windows 10/11 uyumlu olmalı
- Yönetici hakları gerektiriyorsa bunu belirt
- Türkçe karakterleri (ş, ğ, ü, ö, ç, ı) doğru işlemeli