Windows File Names?

Windows specific questions.
cavelamb
Posts: 25
Joined: Jan 04, 2010 9:03
Location: earth
Contact:

Windows File Names?

Postby cavelamb » May 07, 2013 15:54

I think I'm choking on the windows file names that have embedded spaces?
List of folders at the bottom of this page.
Only failing on "C:\My Documents\My Videos"
??
How to handle this?

Code: Select all

'Movie Library list
Dim As Integer MaxFolders, LineCnt, DataLineCnt, FolderCnt, X, X1, X2, FileNum, F_Fatal, TT, FF
Dim As String OneLine, StrTag, Key, FileIn, FileOut, Text, Target
MaxFolders=1024
Dim As String Folders(MaxFolders)
FF = 0
TT = Not FF
F_Fatal = FF

' first thing, read list of folders and validate that they esist.
Print "Reading Folder List"
If Open ("Folders.txt" For Input As #1) = 2  Then ' not found
   Print "Error Reading Data File"
   Key = Input$(1)
   F_Fatal = TT
Else
  LineCnt = 0
  While Not Eof(1)
    Line Input #1, OneLine
    If OneLine <> "" Then
      LineCnt = LineCnt + 1
      Folders(LineCnt) = OneLine
'      Print LineCnt, Folders(LineCnt)
    Else
    End if   
  Wend
  FolderCnt = LineCnt
Close 1
EndIf   

Print "Writing Folders List"
  If open ("MovFolderList.txt" For append As #3) = 2 Then  ' File Not Found
     Print "Error Writing Data File"
     Key = Input$(1)
     F_Fatal = TT     
  Else      
    For x1 = 1 To FolderCnt
     Print #3, Folders(X1)
     Print X1, Folders(X1)
    Next x1   
  Close 3
EndIf 

Print : Print "Paused"
Key = Input$(1)
Print

Print "Validate Folder List"   ' from Folders() array
  For x1 = 1 To FolderCnt
     
      Target = Folders(X1)
      If Right$(Target,1) <>"\" Then Target = Target +"\"
      Target = target + "Test.txt"
    Print "Checking"; X1, Target;
    If Open (Target For Output As #1) = 2  Then  ' not found
      Print " - Folder Not found "
      Folders(X1) = ""
      Print: Print "Paused"
      Key = Input$(1)
      Print
    Else   
       Print
       Close 1
       Kill Target
    EndIf
  Next x1   

Print: Print "Finished"
Key = Input$(1)
Print

End



    C:\!FB\MovieLib\
    C:\My Documents\My Videos
    C:\!
cavelamb
Posts: 25
Joined: Jan 04, 2010 9:03
Location: earth
Contact:

Re: Windows File Names?

Postby cavelamb » May 08, 2013 0:51

Because it's:

C:\DOCUMENTS AND SETTINGS\RICHARD\My Documents\My Videos ???
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Re: Windows File Names?

Postby pestery » May 08, 2013 8:44

...so, you found the problem then? I'm guessing your using Windows XP, because on Vista or Win7 the folder path would be C:\Users\[username]\Documents or C:\Users\[username]\Videos or something else if you changed it.

Have you thought of using Dir for checking if the folders exist instead of open? There are probably a couple of other methods you could also try if you wanted.

Code: Select all

#Include "dir.bi"
Print "Searching for folders..."
Dim As String folder = Dir("*", fbDirectory)
While folder <> ""
   Print "Folder: " & folder
   folder = Dir
Wend
Print "Finished searching"
Sleep
cavelamb
Posts: 25
Joined: Jan 04, 2010 9:03
Location: earth
Contact:

Re: Windows File Names?

Postby cavelamb » May 09, 2013 5:11

pestery wrote:...so, you found the problem then? I'm guessing your using Windows XP, because on Vista or Win7 the folder path would be C:\Users\[username]\Documents or C:\Users\[username]\Videos or something else if you changed it.

Have you thought of using Dir for checking if the folders exist instead of open? There are probably a couple of other methods you could also try if you wanted.

Code: Select all

#Include "dir.bi"
Print "Searching for folders..."
Dim As String folder = Dir("*", fbDirectory)
While folder <> ""
   Print "Folder: " & folder
   folder = Dir
Wend
Print "Finished searching"
Sleep


Hi.
Yeah, after messing with it (Far too long) the light over my head lit up - dimly...

I had not thought about DIR because I did not know how it works.
You example DOES work(!) but there is still some magic involved.
I'll dig into the HELP file and see what that's all about.

DIR might make for a more elegant solution.
But overloaded operators tend to overload my brain.
(it's not pretty when that happens...)
pestery
Posts: 493
Joined: Jun 16, 2007 2:00
Location: Australia

Re: Windows File Names?

Postby pestery » May 10, 2013 3:17

cavelamb wrote:Yeah, after messing with it (Far too long) the light over my head lit up - dimly...
Ha, we've all done that at some point. Probably many times ;-)
Anyway, good luck.

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 2 guests