Windows File Names?

Windows specific questions.
Post Reply
cavelamb
Posts: 52
Joined: Jan 04, 2010 9:03
Location: earth

Windows File Names?

Post by cavelamb »

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: 52
Joined: Jan 04, 2010 9:03
Location: earth

Re: Windows File Names?

Post by cavelamb »

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?

Post by pestery »

...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: 52
Joined: Jan 04, 2010 9:03
Location: earth

Re: Windows File Names?

Post by cavelamb »

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?

Post by pestery »

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.
Post Reply