Defrag system hdd only if is mechanical disk [closed] - powershell

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
we needed some help. in practice we were looking for a method to start the defremmentation (defrag) of the primary disk (on windows "C:") only if it is a HDD and not an SSD
we read about the command in powershell but can't compile (mediaType)

This script should work for you:
#Get friendly name of the C drive
$name = (get-partition -DriveLetter C | get-disk).FriendlyName
#Use friendly name to determine drive type
$mediatype = (Get-PhysicalDisk -FriendlyName $name).MediaType
#Defragment drive if drive type is HDD
if ($mediatype -eq "HDD")
{
Optimize-Volume -DriveLetter C
}

Related

How to style pills in a Word document? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
In an MS Word document, how can I style text into pills, for example like the Bootstrap pills or in the image below?
Doesn't have to be exactly like this, just something similar.
I can highlight a word but it is very limited.
Apologies if this is off topic. I could find a better location.
Additionally, I would rather keep the elements within the flow of the page, so that it can scraped correctly by CV scanners.
I.E. I don't want to insert a load of floating textboxes.
Use a combination of range.border and font properties
Option Explicit
Public Sub MakePill(ByVal ipRange As Word.Range)
' Ensure a space before and after the text in the range
myRange.InsertBefore Text:=" "
ipRange.InsertAfter Text:=" "
myRange.Borders.Enable = True
myRange.Font.Shading.BackgroundPatternColor = wdColorAqua
End Sub

Looking for a way to delete files in a directory depending on their extension's case [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I would love your help with a tool that would greatly simplify my life. As of now I have no scripting knowledge. I am not sure which of powershell or a .bat is the best suited to my need :
I have a folder with thousands of little files with various extension names. Sometimes I need to delete all the files that have their extension written in uppercase, sometimes the ones in lowercase.
I need a script that would ask me in input if I want to delete Upper or Lowercase files and then would go deleting all the files in the folder with an extension in Upper or Lowercase (based on the input).
I have no idea where to begin. Could you please share some ideas ?
Thanks for your time
One way would be to use the -match regular expression operator. Since PowerShell operators always defaults to case-insensitive string comparison, we'll need to qualify it with a c, so -cmatch. To match only upper-case letters, I usually use the regex class \p{Lu} (Lu stands for "Letters, upper"):
$allUppercase = Get-ChildItem -Path C:\path\to\folder\ |Where-Object {$_.Extension -cmatch '^.\p{Lu}+$'}
and now you can delete them with Remove-Item:
$allUppercase |Remove-Item -Force
if you want extensions with lowercase only, test for \p{Ll}:
$allLowercase = Get-ChildItem -Path C:\path\to\folder\ |Where-Object {$_.Extension -cmatch '^.\p{Ll}+$'}

Collect Senders Email Addresses From Specific Folder At Thunderbird [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
as my title mentioned I am searching for a solution to get all email addresses that I have received from people and saved inside a certain folder in my Thunderbird.
I need them for marketing purposes, because those email addresses belong to people I have done business with.
Thanks for help.
Best
RS
You can use Message Filter in order to organize your messages.
Read this article: https://support.mozilla.org/en-US/kb/organize-your-messages-using-filters
Updated:
Select all the emails in that folder and saved them on a directory as a *.eml file format.
In the terminal: cd /path/to/eml/directory Then run:
find . -type f -exec cat {} \; | nl | grep "From" | grep -o '[[:alnum:]+\.\_\-]*#[[:alnum:]+\.\_\-]*' | uniq -ui | sort > collected-emails.csv
Now, All the collected emails will be saved in collected-emails.csv

How do I extract the first x lines from a large CSV file? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Improve this question
How do I extract the first 100,000 lines from a large CSV file (1GB+) using only Powershell on a Windows machine?
Not sure why the below answer was marked as not helpful when it answers the question.
-TotalCount<Int64>
Gets the specified number of lines from the beginning of a file or other item. The default is -1 (all lines).
You can use the "TotalCount" parameter name or its aliases, "First" or "Head".
The performance of the command can be improved by
Get-Content -TotalCount 100000 -ReadCount 0 filename.csv
Get-Content -TotalCount 100000 filename.csv

Correct way of deleting items in a numbered list? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
I have a numbered list in org-mode like
1. A
2. B
3. C
4. D
Now when I kill the second line the list incorrectly gets ordered as,
1. A
3. C
4. D
instead of
1. A
2. C
3. D
I know I can always re-order the list before deleting something, but for long lists this becomes a hassle.
Is there a smarter way to avoid this?
You can kill such lines with no fear in mind. Just use C-c C-c afterwards, or S-right and S-left to go back to the previous list style (with up-to-date numbers).