Search This Blog

Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

Thursday, June 17, 2021

Seeking A but Found (Fascinating) B Part Two

Of course, because I gave up looking and clicked "Publish" for the previous post, it meant I was sentencing myself to have a solution revealed to me when I clicked a link in my search results as this page - https://stackoverflow.com/questions/51076632/exclude-certain-subfolders-when-scanning-the-contents-of-a-folder - revealed the following solution:


for /F "delims=" %%D in ('dir /B /S /A:D "C:\myFolder" ^| findstr /I /V /C:"\\Users\\" /C:"\\Windows\\"') do echo/%%D

with $RECYCLE.BIN listed in the "C:\exclude.txt" file.

for /F "delims=" %%D in ('dir /B /S /A:D "C:\myFolder" ^| findstr /I /V /L /G:"C:\exclude.txt"') do echo/%%D


Seeking A but Found (Fascinating) B

I love DOS, but I don't always understand it. For example, if I go to my I: drive and type:

Dir *.* /s

that command will include the files in my Recycle.bin.

I don't want those files to be included. Thus, I went to Google.com and entered the following search string:

In the search results, I clicked the first line and ended up learning about PowerShell: list the files in the recycle bin older 100 days. Was that what I wanted to know. No, not really. However, I liked the fact that I discovered information about a topic I know very little about - Powershell - to start my day. When I typed: Dir *.* /s at the command line, I saw this result:

And when I changed the directory to I:\$RECYCLE.BIN and entered the Dir *.* /s command, I saw this:

Thus, the actual files on my I: drive is
308495 - 5311 = 303,184
and
the actual directories on my I: drive is
283767 - 160368 = 123,399
When I started my day, all I wanted to do was to go to my I: drive and type dir i:\*.* /s and see
303,184 File(s)
123,399 Dir(s)
Maybe I'll figure out how to do that another day.

Tuesday, April 24, 2018

Knowing But Not Acting

I *KNOW* Powershell is more popular than MS DOS everywhere in the world... except my workstation. At some point, before I retire, I am vowing, right here, right now, to learn Powershell so that all of the MS DOS batch files I presently use will be Powershell commands. Or a script. I'm not even certain what to call it!

To coincide with that proclamation, here's an article to reference: https://superuser.com/questions/851610/tool-that-converts-any-batch-file-into-powershell

I mean, my gosh, this idea to move from MS DOS to Powershell existed in 2009: https://stackoverflow.com/questions/868318/how-can-i-switch-from-cmd-exe-to-powershell

I can also always count on HowtoGeek.com for information: https://www.howtogeek.com/163127/how-powershell-differs-from-the-windows-command-prompt/