Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Script - Create Folder With Inputbox & Move Files/Folders Into It

Status
Not open for further replies.

asldesktop

IS-IT--Management
Apr 5, 2011
5
0
0
GB
Hi

I must point out that I am a novice when it comes to scripting - I can usually get myself through things but I am stuck with this one.

I am attempting to write a script to do the following:

1. Create a folder, the name of which is input in to an inputbox
2. Move the contents of a directory (files & subfolders) in to the newly created subfolder

Sounds simple to me. I have been able to get the part working to create a folder named from an inputbox but not the folder/file move - I get an error 800A004C "Path not found"

Here is the script I have:


************************************************

'Create the file system object for creating folders
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Create A Folder With A Name Given By The User
ParentFolder = "C:\"
set objShell = CreateObject("Shell.Application")
set objFolder = objShell.NameSpace(ParentFolder)
foldername=inputbox ("Enter Folder Name")
objFolder.NewFolder (foldername)

'Move the files and folders in to the new folder
objFSO.MoveFile "C:\logon\*.*" , "foldername"
objFSO.MoveFolder "C:\logon\*.*" , "foldername"

************************************************

Is anyone able to provide assistance so I am able to get this working please? Any help is greatly appreciated!

Thanks

Paul
 
Your post may be better suited in the VB Script forum.
forum329


If at first you don't succeed, then sky diving wasn't meant for you!
 
Apologies - I have replicated this post in the VBScript forum.

Can a mod remove this post please?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top