Windows Vista Forums

Retrieve the path of the file

  1. #1


    AdityaKir Guest

    Retrieve the path of the file

    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 System SpecsSystem Spec

  2. #2


    Keith Hill [MVP] Guest

    Re: Retrieve the path of the file

    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 System SpecsSystem Spec

  3. #3


    Flowering Weeds Guest

    Re: Retrieve the path of the file


    >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 System SpecsSystem Spec

Retrieve the path of the file

Similar Threads
Thread Forum
Re: How do I get absolute path of a file?
ls d:\ -r -i *.doc | %{ write-host "copying $_.fullname to C:\"; cp -literalpath $_.fullname c:\ } On 11/18/2009 8:53 AM, Megaton wrote:
PowerShell
Retrieve file from Recycle Bin issue
Hello, I am running Windows Vista Ultimate 64 bit, and yesterday, when I started my PC up, I was presented with a scaled down version of my...
General Discussion
How to retrieve the latest file
hi, I need to retrieve the latest file in a directory in powershell. Does anybody knows how to do this. Thanks, Aditya
PowerShell
Retrieve File System Object Descriptions For Executables
Hi - I'm a relative new comer to PowerShell, so I struggle with things that are probably old hat for you folks. What I'm wondering is how can I...
PowerShell
Retrieve file version information
Hi, Here's my scenario: I need to retrieve file version information from three different servers. The file name is the same. For example...
PowerShell
Script to retrieve file versions
hi, I found this script on Scripting Guy. However I would like for the window to have the results of three file versions. Here's what I have now....
VB Script
BUG? (Test-Path $path -IsValid) and empty $path
I would like to check if $path is a syntactically valid path using Test-Path with -IsValid switch , i.e.: PS> $path = '' # why not? PS> if...
PowerShell