Recommended Posts

Here ya go. For these to work, you'll need to have XP or download the latest version of Windows Scripting Host from Microsoft - think it's v5.6.

'NewFolder.vbs

Option Explicit
Dim fso, ws, objArgs, Title
Set fso = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject("Wscript.Shell")
Set objArgs = WScript.Arguments
Title = "Create New Folder"

Call MakeNewFolder

Call Cleanup

Sub MakeNewFolder
Dim strArg, FolderTemp, FolderPath, NewFldr
For Each strArg in objArgs
FolderTemp = FolderTemp & " " & strArg
Next
FolderPath = Trim(FolderTemp)
NewFldr = InputBox("Name for New Folder?", Title, "New Folder")
If NewFldr = "" Then Call Cleanup
On Error Resume Next
fso.CreateFolder FolderPath & NewFldr
If Err.Number = 58 Then
Err.Clear:On Error GoTo 0
ws.Popup Chr(34) & NewFldr & Chr(34) & " already exists.", ,Title, 0 + 48 + 4096
Call MakeNewFolder
ElseIf Err.Number = 52 Then
Err.Clear:On Error GoTo 0
ws.Popup Chr(34) & NewFldr & Chr(34) & " contains invalid character(s).", ,Title, 0 + 48 + 4096
Call MakeNewFolder
End If
End Sub

Sub Cleanup
Set ws = Nothing
Set fso = Nothing
WScript.Quit
End Sub  

'NewTextDoc.vbs

Option Explicit
Dim fso, ws, objArgs, Title 
Set fso = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject("Wscript.Shell")
Set objArgs = WScript.Arguments
Title = "Create New Text Document"

Call MakeNewDoc

Call Cleanup

Sub MakeNewDoc
Dim strArg, FolderTemp, FolderPath, NewDoc
For Each strArg in objArgs
FolderTemp = FolderTemp & " " & strArg
Next
FolderPath = Trim(FolderTemp)
NewDoc = InputBox("Name for New Document?", Title, "New Text Document")  
If NewDoc = "" Then Call Cleanup
On Error Resume Next
fso.CreateTextFile FolderPath & NewDoc & ".txt", False
If Err.Number = 58 Then
Err.Clear:On Error GoTo 0
ws.Popup Chr(34) & NewDoc & Chr(34) & " already exists.", ,Title, 0 + 48 + 4096
Call MakeNewDoc
ElseIf Err.Number = 52 Then
Err.Clear:On Error GoTo 0
ws.Popup Chr(34) & NewDoc & Chr(34) & " contains invalid character(s).", ,Title, 0 + 48 + 4096
Call MakeNewDoc
End If
End Sub

Sub Cleanup
Set ws = Nothing
Set fso = Nothing
WScript.Quit
End Sub  

Is there anyway to make it act like the default New Folder/New Text Document menu items do? By that, I mean just have 'em make the folder/file with a default name, and not pop up a dialog like it currently does. I've played with the vbs source a bit, but so far everything I do breaks the script. :D

Edit: Alright, I got it to make a directory/text file without asking for a name, but if it already exists the script goes into an infinite loop. Is it possible to do something like..

if 'NewFoldr' exists

NewFoldr = "New Folder (2)"

Same thing with the New Text Document script.

Edited by RaGe-

RaGe- Something like this you mean?

'NewFolder.vbs
'Version 1.1 for RaGe-

Option Explicit
Dim fso, ws, objArgs, Count
Set fso = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject("Wscript.Shell")
Set objArgs = WScript.Arguments
Count = 0

Call MakeNewFolder

Call Cleanup

Sub MakeNewFolder
Dim strArg, FolderTemp, FolderPath, NewFldr
For Each strArg in objArgs
FolderTemp = FolderTemp & " " & strArg
Next
FolderPath = Trim(FolderTemp)
If Count = 0 Then
NewFldr = "New Folder"
Else
NewFldr = "New Folder (" & Count & ")"
End If
On Error Resume Next
fso.CreateFolder FolderPath & NewFldr
If Err.Number = 58 Then
Err.Clear:On Error GoTo 0
Count = Count + 1
Call MakeNewFolder
End If
End Sub

Sub Cleanup
Set ws = Nothing
Set fso = Nothing
WScript.Quit
End Sub ?

'NewTextDoc.vbs
'Version 1.1 for RaGe-

Option Explicit
Dim fso, ws, objArgs, Count 
Set fso = CreateObject("Scripting.FileSystemObject")
Set ws = CreateObject("Wscript.Shell")
Set objArgs = WScript.Arguments
Count = 0

Call MakeNewDoc

Call Cleanup

Sub MakeNewDoc
Dim strArg, FolderTemp, FolderPath, NewDoc
For Each strArg in objArgs
FolderTemp = FolderTemp & " " & strArg
Next
FolderPath = Trim(FolderTemp)
If Count = 0 Then
NewDoc = "New Text Document" 
Else
NewDoc = "New Text Document (" ?& Count & ")"
End If
On Error Resume Next
fso.CreateTextFile FolderPath & NewDoc & ".txt", False
If Err.Number = 58 Then
Err.Clear:On Error GoTo 0
Count = Count + 1
Call MakeNewDoc
End If
End Sub

Sub Cleanup
Set ws = Nothing
Set fso = Nothing
WScript.Quit
End Sub ?

BTW, please note that I'm not exactly a vbscript guru. It took me about a month to get these scripts working in the first place so no really difficult questions pleas:D :D

Did it anyway :D

'Begin code for FileExtXP.vbs
'Version: 1.0 - Windows XP (October 9, 2003)

Option Explicit
Dim WSHShell, RegKey, FileExt
Set WSHShell = CreateObject("WScript.Shell")
RegKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\"
FileExt = WSHShell.RegRead (RegKey & "HideFileExt")

If FileExt = 1 Then ? 'File extensions hidden
 ? ? ?WSHShell.RegWrite RegKey & "HideFileExt", 0, "REG_DWORD" ? 'Show file extensions
Else
 ? ? ?WSHShell.RegWrite RegKey & "HideFileExt", 1, "REG_DWORD" ? 'Hide file extensions
End If

WSHShell.SendKeys "+{F10}e" ? 'Refresh

Actually, I have a bit of a question...

Neither the New Text Doc nor the New Folder scripts work. I can double-click them in the folder I hold them in and they do what they're supposed to, but when I use the context menu they don't work... Any suggestions?

First of all, I have to say, THANK YOU!!! These vbs scripts are awesome and very useful, especially the show file extensions and show/hide folders.. I've seen the New Folder option in other tweak progs. Just one thing, however. I can't seem to get the New folder vbs to work. Well, actually, it does work but it creates the new folder in Documents and Settings\Gabe Flores directory instead of the directory i'm currently in. Any suggestions? Thanks again!

ps: do you know of a way to remove a bunch of junk from the context menu, such as "move to folder" and "customize this folder" and the Windows Media Player context menu, among other things? Thanks.

Edited by gflores
do you know of a way to remove a bunch of junk from the context menu, such as "move to folder"  and "customize this folder" and the Windows Media Player context menu, among other things? Thanks.

Download a program called X-Setup. This will let you remove a bunch of stuff from your context menus.

As far as I can remember, to remove the WMP context menu options you have to unregister a dll. Try typing

regsvr32 /u wmpshell.dll

in the run box.

If you need any more help just let me know :)

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.