View Single Post
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