Преглед на файлове

Update 'LZX-Compression-Automated.ps1'

nathan преди 1 година
родител
ревизия
5cbd1a45a6
променени са 1 файла, в които са добавени 55 реда и са изтрити 1 реда
  1. 55
    1
      LZX-Compression-Automated.ps1

+ 55
- 1
LZX-Compression-Automated.ps1 Целия файл

@@ -1,5 +1,35 @@
1
+# Prompt the user to enter the type of drive they are planning to use this on
2
+$driveType = Read-Host "Please enter the type of drive you are planning to use this on (SSD or HDD)"
3
+
4
+# Validate the drive type input
5
+if ($driveType -eq "SSD" -or $driveType -eq "HDD") {
6
+    # Proceed with the script
7
+} else {
8
+    # Display an error message and exit the script
9
+    Write-Error "Invalid drive type. Please enter either SSD or HDD."
10
+    Exit
11
+}
12
+
13
+# If the drive type is SSD, inform the user of the pros of compression
14
+if ($driveType -eq "SSD") {
15
+    Write-Host "Compressing files and folders on a solid state drive (SSD) can have some benefits, such as:"
16
+    Write-Host "- You can save some disk space by compressing files and folders that are not already compressed or optimized. This can help you store more data on your SSD or free up some space for other purposes."
17
+    Write-Host "- You can improve the performance of your SSD by reducing the amount of data that needs to be read and written. This can lower the wear and tear of your SSD and extend its lifespan. It can also reduce the power consumption and heat generation of your SSD, which can benefit your battery life and system stability."
18
+    Write-Host "- You can enhance the security of your data by making it harder for unauthorized users or programs to access or modify your files. Compression can also help you recover some data in case of corruption or deletion, as it may preserve some parts of the original file."
19
+    Write-Host "However, there are also some cons of using this script on an SSD, such as:"
20
+    Write-Host "- You may experience some CPU overhead when compressing and decompressing files, which can affect your system performance and responsiveness. This may not be noticeable on modern CPUs, but it can still have some impact on your multitasking and gaming experience."
21
+    Write-Host "- You may encounter some compatibility issues with some applications or games that do not support compressed files or folders. This can cause errors, crashes, or performance degradation. You may need to decompress some files or folders before using them with certain programs."
22
+    Write-Host "- You may lose some data quality or functionality when compressing some types of files, such as audio, video, or document files. Compression can reduce the resolution, bitrate, or features of these files, which can affect their appearance, sound, or behavior."
23
+    Write-Host "Therefore, you should weigh the pros and cons of using this script on an SSD before deciding to do so. You should also backup your important data before running the script, in case something goes wrong. You can read more about how compression works on SSDs in [this article](^3^) or this question."
24
+}
25
+
26
+# If the drive type is HDD, inform the user of the benefits of compression
27
+if ($driveType -eq "HDD") {
28
+    Write-Host "Compressing files and folders on a hard disk drive (HDD) can improve performance by reducing disk space usage, increasing data transfer speed, and reducing seek time. However, compression also increases CPU usage and may affect some applications or games. You can read more about the pros and cons of compression on HDDs in [this article](^2^)."
29
+}
30
+
1 31
 # Prompt the user to enter a drive letter for compression
2
-$drive = Read-Host "Please enter a drive letter for compression (e.g. C, D, E, F, etc.)"
32
+$drive = Read-Host "Please enter a drive letter for compression (e.g. C, D, E)"
3 33
 
4 34
 # Validate the drive letter input
5 35
 if ($drive -match "^[A-Z]$") {
@@ -39,3 +69,27 @@ foreach ($item in $items) {
39 69
     # Compress the item using compact.exe with the /C, /I, /EXE:lzx and /EXCLUDE:exclude.txt options
40 70
     compact /C /I /EXE:lzx /EXCLUDE:exclude.txt $item.FullName
41 71
 }
72
+
73
+# Prompt the user if they wish to undo compression in case of compatibility reasons
74
+$undo = Read-Host "Do you wish to undo compression in case of compatibility reasons? (Y/N)"
75
+
76
+# Validate the undo input
77
+if ($undo -eq "Y" -or $undo -eq "N") {
78
+    # Proceed with the script
79
+} else {
80
+    # Display an error message and exit the script
81
+    Write-Error "Invalid input. Please enter either Y or N."
82
+    Exit
83
+}
84
+
85
+# If the user wishes to undo compression, run the command to uncompress the data
86
+if ($undo -eq "Y") {
87
+    Write-Host "Uncompressing the data. This may take some time."
88
+    compact.exe /CompactOS:never
89
+    Write-Host "The data has been uncompressed. You may need to restart your system for the changes to take effect."
90
+}
91
+
92
+# If the user does not wish to undo compression, display a message and exit the script
93
+if ($undo -eq "N") {
94
+    Write-Host "The data has been compressed. You may need to restart your system for the changes to take effect."
95
+}

Powered by TurnKey Linux.