• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Retrieve the path of the file

A

AdityaKir

#1
Hi,

I have a requirement where in I know the name of the file. But do not know
the complete path of its location. Moreover the machine will be having
atleast 3 drives. Is there any way to retrieve the path of the specified File
only by giving the name.


Thanks,

Aditya
 

My Computer

K

Keith Hill [MVP]

#2
I think this requires a brute force approach:

'c:\','d:\','e:\' | get-childitem -r -filter *.txt -force | where
{!$_.PSIsContainer -and $_.name -eq $filename}

For $filename specify the entire filename that you want to match including
the extension. For the command above I assumed a filter of .txt, change
that to whatever extension the file you're looking for uses.

--
Keith

"AdityaKir" <AdityaKir@xxxxxx> wrote in message
news:39BF9223-4A0E-4715-973E-0211FC44A78B@xxxxxx

> Hi,
>
> I have a requirement where in I know the name of the file. But do not
> know
> the complete path of its location. Moreover the machine will be having
> atleast 3 drives. Is there any way to retrieve the path of the specified
> File
> only by giving the name.
>
>
> Thanks,
>
> Aditya
 

My Computer

F

Flowering Weeds

#3

>I think this requires a brute force approach:
>
> 'c:\','d:\','e:\' | get-childitem
Or the same ways one,
in other Windows processes,
uses many other Windows tools
to find files!

Where.exe

The automation (PowerShell) tool's
cmdlet get-command where.exe
returns:

FileDescription:
Where - Lists location of files

Product:
Microsoftr Windowsr Operating System

Or another Windows tool

LogParser.exe -h -i:fs

returns:

Input format: FS (FileSystem properties)
Returns properties of files and folders

Yep there are many Windows tools
(where.exe, powershell.exe, logparser.exe
and etc.) that can help one find files!
 

My Computer

Users Who Are Viewing This Thread (Users: 1, Guests: 0)