![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | creating complete file path Hello, The FileSystemObjects CreateFolder() can only create one folder at a time. e.g. CreateFolder(c:\temp) CreateFolder(c:\temp\tempsub) ... How can I create a given path "c:\temp\tempsub" at a time (or in a loop)? Thank You Joachim |
My System Specs![]() |
| | #2 (permalink) |
| | Re: creating complete file path Joachim Hofmann schrieb: Quote: > Hello, > > The FileSystemObjects CreateFolder() can only create one folder at a time. > e.g. > > CreateFolder(c:\temp) > CreateFolder(c:\temp\tempsub) > .. > > > How can I create a given path "c:\temp\tempsub" at a time (or in a loop)? > > Thank You > > Joachim http://www.visualbasicscript.com/fb.aspx?m=38936 |
My System Specs![]() |
| | #3 (permalink) |
| | Re: creating complete file path "Joachim Hofmann" <speicher@xxxxxx> wrote in message news:%235vEfmLFJHA.2456@xxxxxx Quote: > Hello, > > The FileSystemObjects CreateFolder() can only create one folder at a time. > e.g. > > CreateFolder(c:\temp) > CreateFolder(c:\temp\tempsub) into any scripts I need this functionality in. Just use syntax like 'CreatePath "C:\One\Two\Three\Four", False'. Function CreatePath(ByVal sPathName, ByVal bQuitOnFail) Dim oFSO, sPath, sString, aPath Set oFSO = CreateObject("Scripting.FileSystemObject") aPath = Split(sPathName, "\") On Error Resume Next For Each sString in aPath If Len(sString) Then sPath = sPath & String(Abs(Len(sPath) > 0),"\") & sString If Not oFSO.FolderExists(sPath) Then oFSO.CreateFolder(sPath) End If End If Next On Error Goto 0 CreatePath = oFSO.FolderExists(sPathName) If bQuitOnFail And Not CreatePath Then MsgBox "Unable to create Folder:" & vbCrLf & sPathNAme, vbExclamation, "Quitting!" If Not TypeName(oIE) = "Object" Then oIE.Quit WScript.Quit End If End Function |
My System Specs![]() |
| | #4 (permalink) |
| | Re: creating complete file path ekkehard.horner wrote: Quote: > Joachim Hofmann schrieb: Quote: > > Hello, > > > > The FileSystemObjects CreateFolder() can only create one folder at a Quote: Quote: > > e.g. > > > > CreateFolder(c:\temp) > > CreateFolder(c:\temp\tempsub) > > .. > > > > > > How can I create a given path "c:\temp\tempsub" at a time (or in a Quote: (Remove the close parenthesis preceding the ampersand.) -- Todd Vargo (Post questions to group only. Remove "z" to email personal messages) |
My System Specs![]() |
| | #5 (permalink) |
| | Re: creating complete file path "Todd Vargo" <tlvargo@xxxxxx> wrote in message news:O6%23lfUUFJHA.768@xxxxxx Quote: > ekkehard.horner wrote: Quote: >> Joachim Hofmann schrieb: Quote: >> > Hello, >> > >> > The FileSystemObjects CreateFolder() can only create one folder at a Quote: Quote: >> > e.g. >> > >> > CreateFolder(c:\temp) >> > CreateFolder(c:\temp\tempsub) >> > .. >> > >> > >> > How can I create a given path "c:\temp\tempsub" at a time (or in a Quote: Quote: >> > >> > Thank You >> > >> > Joachim >> see >> http://www.visualbasicscript.com/fb.aspx?m=38936 > Excellent subroutine, but mind the typo in the example calling line. > (Remove the close parenthesis preceding the ampersand.) SmartCreateFolder(WSHShell.ExpandEnvironmentStrings ("%SystemDrive%") & "\Program Files\Name1\Name2" ) to this: SmartCreateFolder(WSHShell.ExpandEnvironmentStrings ("%SystemDrive%" & "\Program Files\Name1\Name2" ) ? Now we have more opening parens than closing ones - surely a syntax error in either case. I would propose this: SmartCreateFolder(WSHShell.ExpandEnvironmentStrings ("%SystemDrive%" & "\Program Files\Name1\Name2" )) But then we could reduce the concatenation of two literal strings to one literal string, i.e.: SmartCreateFolder(WSHShell.ExpandEnvironmentStrings ("%SystemDrive%\Program Files\Name1\Name2" )) And we could further reduce the redundant outer parens: SmartCreateFolder WSHShell.ExpandEnvironmentStrings ("%SystemDrive%\Program Files\Name1\Name2" ) /Al |
My System Specs![]() |
| | #6 (permalink) |
| | Re: creating complete file path "Al Dunbar" <AlanDrub@xxxxxx> wrote in message news:u3JmXmUFJHA.612@xxxxxx Quote: > > "Todd Vargo" <tlvargo@xxxxxx> wrote in message > news:O6%23lfUUFJHA.768@xxxxxx Quote: >> ekkehard.horner wrote: Quote: >>> Joachim Hofmann schrieb: >>> > Hello, >>> > >>> > The FileSystemObjects CreateFolder() can only create one folder at a Quote: >>> > e.g. >>> > >>> > CreateFolder(c:\temp) >>> > CreateFolder(c:\temp\tempsub) >>> > .. >>> > >>> > >>> > How can I create a given path "c:\temp\tempsub" at a time (or in a Quote: >>> > >>> > Thank You >>> > >>> > Joachim >>> >>> see >>> http://www.visualbasicscript.com/fb.aspx?m=38936 >> Excellent subroutine, but mind the typo in the example calling line. >> (Remove the close parenthesis preceding the ampersand.) > So you are saying to change this: > > SmartCreateFolder(WSHShell.ExpandEnvironmentStrings ("%SystemDrive%") & > "\Program Files\Name1\Name2" ) > > to this: > > SmartCreateFolder(WSHShell.ExpandEnvironmentStrings ("%SystemDrive%" & > "\Program Files\Name1\Name2" ) > > ? Now we have more opening parens than closing ones - surely a syntax > error in either case. > > I would propose this: > > SmartCreateFolder(WSHShell.ExpandEnvironmentStrings ("%SystemDrive%" & > "\Program Files\Name1\Name2" )) > > But then we could reduce the concatenation of two literal strings to one > literal string, i.e.: > > SmartCreateFolder(WSHShell.ExpandEnvironmentStrings > ("%SystemDrive%\Program Files\Name1\Name2" )) > > And we could further reduce the redundant outer parens: > > SmartCreateFolder WSHShell.ExpandEnvironmentStrings > ("%SystemDrive%\Program Files\Name1\Name2" ) SmartCreateFolder WSHShell.ExpandEnvironmentStrings("%ProgramFiles%\Name1\Name2" ) /Al |
My System Specs![]() |
| | #7 (permalink) |
| | Re: creating complete file path Todd Vargo schrieb: Quote: > ekkehard.horner wrote: Quote: >> Joachim Hofmann schrieb: Quote: Quote: Quote: >>> How can I create a given path "c:\temp\tempsub" at a time (or in a loop)? Quote: Quote: > Excellent subroutine, but mind the typo in the example calling line. > (Remove the close parenthesis preceding the ampersand.) SmartCreateFolder(WSHShell.ExpandEnvironmentStrings ("%SystemDrive%") & "\Program Files\Name1\Name2" ) the close parenthesis preceding the ampersand is needed for the call of ..ExpandEnvironmentStrings. According to the rule "no parameter list parentheses when callg a sub", the *first* pair of () should be removed. |
My System Specs![]() |
| | #8 (permalink) |
| | Re: creating complete file path "ekkehard.horner" <ekkehard.horner@xxxxxx> wrote in message news:48cb53a8$0$3551$9b4e6d93@xxxxxx-online.net... Quote: > Todd Vargo schrieb: Quote: >> ekkehard.horner wrote: Quote: >>> Joachim Hofmann schrieb: Quote: Quote: >>>> How can I create a given path "c:\temp\tempsub" at a time (or in a >>>> loop)? Quote: Quote: >> Excellent subroutine, but mind the typo in the example calling line. >> (Remove the close parenthesis preceding the ampersand.) > I can't rule out that the line was changed recently, but as it is now > > SmartCreateFolder(WSHShell.ExpandEnvironmentStrings ("%SystemDrive%") & > "\Program Files\Name1\Name2" ) > > the close parenthesis preceding the ampersand is needed for the call of > .ExpandEnvironmentStrings. intent. That said, expandenvironmentstrings expands as batch does, and does not need to be limited to one evn var per call. /Al Quote: > According to the rule "no parameter list parentheses when callg a sub", > the > *first* pair of () should be removed. > |
My System Specs![]() |
| | #9 (permalink) |
| | Re: creating complete file path Al Dunbar wrote: Quote: Quote: > > And we could further reduce the redundant outer parens: > > > > SmartCreateFolder WSHShell.ExpandEnvironmentStrings > > ("%SystemDrive%\Program Files\Name1\Name2" ) > Or even: > > SmartCreateFolder > WSHShell.ExpandEnvironmentStrings("%ProgramFiles%\Name1\Name2" ) Windows 98, therefore I had only read the code without testing. ![]() -- Todd Vargo (Post questions to group only. Remove "z" to email personal messages) |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Extracting drive, path filebasename or extension from complete filename? | VB Script | |||
| Command Prompt Auto Complete and path Completion | Vista General | |||
| finding path to an .exe file | Vista file management | |||
| rundll error while creating app path key | Vista General | |||
| BUG? (Test-Path $path -IsValid) and empty $path | PowerShell | |||