Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Reading CD/DVDs and saving directory infornation to a text file

Reply
 
Old 05-30-2008   #1 (permalink)
TimParker


 
 

Reading CD/DVDs and saving directory infornation to a text file

I am trying to write what I think is a simple script while I am still
learning Powershell. I have a stack of CD/DVDs (backups) that have
been made by my predecessors. Since I don't have much more to go on
other than the cryptic notes scribbled on the CDs I thought I would
read the directories and output them to text files that I can then
search later when I am looking for items for users.

I have the script working to where I can see the output and it looks
"pretty" but when I try and output it to a text file it becomes all
jumbled up. I am sure I am piping it out in the wrong way but really
need to get this done as I have some requests now that are starting to
pile up (transcription is backed up and they need the files).

Here is what I have:

#I am copying the title by hand of what is scribbled on the CD so I
know which one to grab.
$title = "Misc Cleanup 3/28/2008"

#Just putting the contents into a variable of the entire CD/DVD
$files = dir -recurse "\\wkstnlap01\lap01cd\

#this is the extent of the data that I want to output to the text file
the title with a couple line breaks and then the #output of the File
Stream.
#$title + "`n`n" + $files > z:\outputFile.txt

If I view the file in Notepad this is what I see below. I would like
to be formatted like a normal directory. If I output the $files by
itself in Powergui It shows up just like I typed DIR on the directory
in question.

Misc Cleanup 3/28/2008 from mops1 from team child TonyIssenmann DB
Dictation My Documents WINDOWS lookup2001 CIS File Management.mdb
Lookup 2001 Network.mdb Current Current_old_2_07 Send
Send_old_10_31_07 Send_old_2_07 Send_old_4_25_07 test 1166_1.dau
1166_3.dau 1168_1.dau 1169_1.dau 1169_2.dau 1171_4.dau 1172_2.dau
1172_8.dau 1175_0.dau 1175_1.dau 1175_2.dau 1175_3.dau 1176_0.dau
1176_1.dau

TIA.

Tim


My System SpecsSystem Spec
Old 05-30-2008   #2 (permalink)
Marco Shaw [MVP]


 
 

Re: Reading CD/DVDs and saving directory infornation to a text file

Quote:

> #$title + "`n`n" + $files > z:\outputFile.txt
This is basically forcing $files into a string object, thus "compacting"
everything (removing the line breaks).

You could move to doing this step-by-step:
$title >> z:\outputfile.txt
$files >> z:\outputfile.txt

Marco

--
Microsoft MVP - Windows PowerShell
http://www.microsoft.com/mvp

PowerGadgets MVP
http://www.powergadgets.com/mvp

Blog:
http://marcoshaw.blogspot.com
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Reading A Text File VB Script
Reading text file at a URL VB Script
Reading a text file with StreamReader .NET General
Refresh on Reading more than one variable from a Text file VB Script
Reading text file and charting them via powergadget PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46