Build a File

Welcome Forums General PowerShell Q&A Build a File

Viewing 5 reply threads
  • Author
    Posts
    • #34919
      Participant
      Topics: 28
      Replies: 80
      Points: 0
      Rank: Member

      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
      Participant
      Topics: 16
      Replies: 108
      Points: 0
      Rank: Member

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

    • #34921
      Participant
      Topics: 28
      Replies: 80
      Points: 0
      Rank: Member

      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
      Participant
      Topics: 6
      Replies: 236
      Points: 0
      Rank: Member
      ls | select -ExpandProperty FullName | Out-File test.txt
      ls | select -Property FullName | Export-Csv test.csv
      
    • #34923
      Participant
      Topics: 16
      Replies: 108
      Points: 0
      Rank: Member

      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
      Participant
      Topics: 28
      Replies: 80
      Points: 0
      Rank: Member

      Thank you!

Viewing 5 reply threads
  • The topic ‘Build a File’ is closed to new replies.