Skip to main content

Windows search location of files


Search directory and path location of Windows files using “where” command.

Where is a command line tool. Since it's a command line tool it can be automated using a batch file or any scripting of your choice.

Here’s an example of where command:

         where /R  c:\users\username *.doc  *.xls                   

Command above will find all document files and excel files in folders and subfolders of c:\users\username. /R is an option to search recursively.

The above command just use a space as a delimiter to set a parameter for other files to include on the search.

The complete path and file name for all files matching will be displayed.

But it’s better to specify a specific path; the more folders to search recursively then the longer it takes to find the matching files.


       where /R  c:\users\ My*.doc 

Command above will search for documents a file that begins with “My” on its filename. The path is on C:\users, if the user is executing has proper right to access the folder of other users. Then the output will include the files of other users. 


From Windows help the parameter of list is:

Parameter List:
    /R       Recursively searches and displays the files that match the
             given pattern starting from the specified directory.

    /Q       Returns only the exit code, without displaying the list
             of matched files. (Quiet mode)

    /F       Displays the matched filename in double quotes.

    /T       Displays the file size, last modified date and time for all
             matched files.



Cheers.. Till next time..

Comments

Popular posts from this blog

Copy a single file using robocopy

Copy a single file using robocopy from a local folder to a shared folder on the network.
A simple rule of thumb before any disaster strike, don't interchange the source and the destination.

If source and destination is mistakenly reverse, files might get overwritten. To avoid any loss of data do a test with a dummy file to ensure things work perfectly.
Robocopy [source][destination]   [file to be copied]
robocopy c:\local_c_folder  \\PC_network\shared_folder   file_to_be_copied_xx.txt
The command will be completed successfully provided the network access right has no issues.

Robocopy works quite good on large files. A simple copy or xcopy command will also work but the speed might vary.

Robocopy is free it can be accessed from command line. No need to install the resource kit tool if the operating system is Windows 7 or newer version.

Copy files with selected file extension using PowerShell and Robocopy:

$extension = ('.pdf', '.jpg', '.txt')
gci d:\WorkFolde…

WMIC get computer name

WMIC get computer model, manufacturer, computer name and  username.
WMIC is a command-line tool and that can generate information about computer model, its manufacturer, its username and other informations depending on the parameters provided.
Why would you need a command line tool if there’s a GUI to check?
If you have 20 or 100 computers, or even more. It’s quite a big task just checking the GUI to check the computer model and username.
If you have remote computers, you need to delegate someone in the remote office or location to check.
Or you can just write a batch file or script to automate the task.
Here’s the code below on how get computer model, manufacturer and the username.
Open an elevated command prompt and type:
wmic computersystem get "Model","Manufacturer", "Name", "UserName"
Just copy and paste the code above, the word “computersystem” does not need to be change to a computer name.
A sample output below will be generated if the co…