how do I find all exe files using command line for windows? - windows

I'm a newbie. I am trying to figure out how to use the command line. Please could you tell me what command I should enter so that I can get a list of all the exe files on my computer. thanks.

You can use the dir functionality to search the directory and all of its children directories while filtering on a particular file type.
dir /s /b *.exe | findstr /v .exe.
Source

If you want to find all the executable files that are on the path and/or in the current directory, i.e., all the files you can run from the command line without specifying a path, this should work:
where *.exe

To get names of all .exe files , that are currently running then type tasklist in cmd.
http://ss64.com/nt/tasklist.html

Here's another method I use a lot for tasks like this.
Open powershell and navigate to your root directory by entering the command
cd c:/
cd stands for change directory, and is an alias for the command "Set-Location". We are setting the location to C:/
Next run the following command:
Get-ChildItem -Filter "*.exe" -Recurse
Get-ChildItem is a function that gets the files and folders in a file system drive, and runs on whatever directory you're current at by default.
-Filter "*.exe" is an argument that specifies to only find filenames which end in ".exe". (The * is a type of regular expression notation).
-Recurse is an argument that specifies to search all child directories. This will make your function run on "C:/", but also all child directories of C:/, and all child directories of those directories and so on. This will allow you to search the entire drive.

Related

Analog of $PWD in Windows

I run windows command in particular directory and I need to pass files and subdirectories in this directory with full path. How to retrieve full path of current directory? What is analog of bash $PWD?
$pwd is indeed a valid command in PowerShell as well (if you're using PowerShell). $pwd in PowerShell is basically an alias for Get-Location - both of them will give you the full path of current directory.
In case you are using cmd, use cd (just cd without any parameters)

How to find all header files in directory and subdirectories in Windows

i recently started working on windows operation system(2012 R2) and i am trying to find all files with header format (*.h) in my directory and it subdirectories .
this how i got it when i ran in linux shell :
find /auto/sw_work/fwshared/ibrahims/git/svx/pci_verification -name "*.h"
i got the following results :
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/BlockStateMainProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/BlueFieldBdfProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/CfgLastIndexProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/CfgLastIndexPropertyProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/ComponentIsUpstreamProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/ConfigTraceProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/DmesgProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/DriverProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/HeaderLogProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/HotPlugProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/I1FrequencyProperty.h
/auto/sw_work/fwshared/ibrahims/git/svx/pci_verification/pci_properties/src/LinkEqProperty.h
how can i get the following results when running in windows command line?
thank in advance .
That's an easy one.
The command to list files is dir. See dir /? for various switches.
dir /s /b "\auto\sw_work\fwshared\ibrahims\git\svx\pci_verification\*.h"
The /s switch looks recursive (including subfolders), the /b switch will show the files in bare format (no header, no summary, timestamps or size)
Note: the directory separator in Windows is \, not / as in Unix/Linux.

How to use short-cut paths to Compress-Archive to zip current folder into same destination

I am using Compress-Archive and want to zip the current directory into the same path. However I do not want to have to type out the entire file path both times. Is there an easy way to do this?
I am using windows 10 pro.
This works for the most part Compress-Archive . test.zip but I want it to be on the same level as the current directory so I need to put it back one spot.
Something like this is what I want:
path/test
path/test.zip
What I am getting:
path/test
path/test/test.zip
It is going inside the actual folder which is not what I want
You propably want that:
Compress-Archive * ..\test.zip
The wildcard * avoids that the name of the folder is put inside the zip.
Using .. for the output path we go one level up in the directory tree.
This command will fail if test.zip already exists. Either add parameter -update to update the archive or add -force to overwrite the archive. Both can be used even if the archive does not already exist.
If the current working directory is "t", it can be included using the following command. I would note that I do not think putting the destination .zip file in the directory being compressed is a good idea.
Compress-Archive -Path $(Get-ChildItem -Recurse -Exclude t.zip) -DestinationPath .\t.zip -Force
It is shorter if you are willing to use aliases and cryptic switches.
Compress-Archive $(gci -r -e t.zip) .\t.zip -Force
If I have misinterpreted your situation, please leave a comment or improve the information provided by editing the question.

Renaming a file and remove 'dot' and replace it with' _'

I have set of files in a folder with name like abcd.15678
I want to remove the . and replace it with _
Pls suggest the windows command to do this
This solution is reposted from How to Batch Rename Files in Windows: 4 Ways to Rename Multiple Files by Chris Hoffman
PowerShell offers much more flexibility for renaming files in a command-line environment. Using PowerShell, you can pipe the output of one command – known as a “commandlet” in PowerShell terms — to another command, just like you can on Linux and other UNIX-like systems.
First of all, open Powershell ISE and then navigate to the directory (folder) that has the files and folders you'd like to rename by using this command:
cd "C:\your\directory\"
The two important commands you’ll need are Dir, which lists the files in the current directory, and Rename-Item, which renames an item (a file, in this case). Pipe the output of Dir to Rename-Item and you’re in business.
After you launch PowerShell ISE, use the cd command to enter the directory containing your files. You should put the files in their own directory so you don’t accidentally rename other files.
For example, let’s say we don’t want the dot character in our file names – we’d rather have an underscore instead.
The following command lists the files in the current directory and pipes the list to Rename-Item. Rename-Item replaces each dot character with an underscore.
Dir | Rename-Item –NewName { $_.name –replace ".","_" }
Consult Microsoft’s documentation on the Rename-Item commandlet if you want help performing other, more advanced operations.
There isn't a windows command to do this. You should consider writing a script of some sort that obtains a directory listing and enumerates through each entry: changes the dot to an underscore, and calls the windows rename command appropriately.
Actually this should work :
Dir | Rename-Item –NewName { $_.Name.Replace(".","_") }

Create an Array containing filenames in a directory

I'm trying to copy one or two specific files from a bunch of directories (hence why I don't want to/can't use *) from one directory to another using a batch script.
Basically I want to navigate into a "root directory" and from that list all the sub-directories using dir /AD-H /B then I want to cd into each of those directories and xcopy /y into a directory I have stored in a variable.
I've tried some examples I've found on the web, but when I've modified them they have not been able to handle the switches properly.
Thanks
Look into PHP an list the directory recursively into an array, here is a Example but you would need to modify it to fit your needs
With PowerShell, you can use something like:
Get-ChildItem C:\ | ? {if ($_.PSIsContainer) {Copy-Item -include MyFile1.ABC -path $_.FullName -destination ("E:\Test\" + $_.Name) -recurse}}
Replace C:\ with the "Root Directory" to copy from and replace "E:\Test\" with the "Root Directory" to copy to (or to use an environmental variable DestX, replace "E:\Test\" with $env:DestX.

Resources