Build a File

This topic contains 5 replies, has 3 voices, and was last updated by Profile photo of 37mm 37mm 7 months, 3 weeks ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #34919
    Profile photo of 37mm
    37mm
    Participant

    I want to build a .txt file that has every file in a directory full path on each line.

    ls | select name | Out-File test.txt

    This is the contents test.txt

    
    Name             
    ----             
    jns22.txt   
    gps-position1.txt
    gps-position2.txt
    gps-position3.txt
    gps-position6.txt      
    

    What I am looking for is the full path, and I don't want the column header (Name).

    Thanks in advance Fellas!

    #34920
    Profile photo of Wilfredo Perez
    Wilfredo Perez
    Participant

    Does it have to be a txt file. Can it be a csv file?

    #34921
    Profile photo of 37mm
    37mm
    Participant

    No it doesn't have to a txt file. Now that I think of it, a csv would fix my issue! I don't think it will give me the full path of the file though.

    #34922
    Profile photo of Bob McCoy
    Bob McCoy
    Participant
    ls | select -ExpandProperty FullName | Out-File test.txt
    ls | select -Property FullName | Export-Csv test.csv
    
    #34923
    Profile photo of Wilfredo Perez
    Wilfredo Perez
    Participant

    You will need to use Fullname instead of name. Try something like this:

    (Get-ChildItem c:\ -Recurse).FullName | export-CSV c:\test.csv
    

    Also this one:

    Get-ChildItem c:\ -Recurse | out-file C:\Test\file.txt
    
    #34924
    Profile photo of 37mm
    37mm
    Participant

    Thank you!

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.