Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

vb script

Posted on 2008-11-17
4
Medium Priority
?
223 Views
Last Modified: 2012-05-05
i have a vb script that i am trying to move files from one directory to another.  i have a text file that contains the files i need to copy.  my problem is the extension are not listed in the text file. so i thought that i could concantenate the extensions with & "*.*" i get the error (object doesn't support this property).

Dim objShell, objFSO, objFile
Dim strCopyFrom, strfolderName, strCopyTo
Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strCopyFrom = "d:\\cadd\pdf manuals"
strCopyTo = "d:\\cadd\pdf manuals\ProductInspection"
'on error resume next

Set objFile = objFSO.OpenTextFile("d:\cadd\pdf manuals\manual.txt")
    objfile = objFile & "*.*"
Do While not objFile.AtEndOfStream
      strFolderName = objFile.Readline
      objFSO.copyFile strCopyFrom & "\" & strFolderName, strCopyTo & "\" & strFolderName
Loop
0
Comment
Question by:MNAdmin
  • 2
4 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 22976502
What if you simply remark that line out...?
Dim objShell, objFSO, objFile
Dim strCopyFrom, strfolderName, strCopyTo
Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
 
strCopyFrom = "d:\\cadd\pdf manuals"
strCopyTo = "d:\\cadd\pdf manuals\ProductInspection"
'on error resume next
 
Set objFile = objFSO.OpenTextFile("d:\cadd\pdf manuals\manual.txt")
'    objfile = objFile & "*.*"
Do While not objFile.AtEndOfStream
      strFolderName = objFile.Readline
      objFSO.copyFile strCopyFrom & "\" & strFolderName, strCopyTo & "\" & strFolderName
Loop

Open in new window

0
 

Author Comment

by:MNAdmin
ID: 22976532
then it gives me file not found
0
 
LVL 38

Accepted Solution

by:
Shift-3 earned 1000 total points
ID: 22976811
If I'm reading your question correctly, the file manual.txt contains the names of files (without extensions) which exist in the folder d:\cadd\pdf manuals.  If this is the case then the below should work.
 


Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strCopyFrom = "d:\cadd\pdf manuals"
strCopyTo = "d:\cadd\pdf manuals\ProductInspection"
'on error resume next
 
Set objFile = objFSO.OpenTextFile("d:\cadd\pdf manuals\manual.txt")
 
Do While not objFile.AtEndOfStream
    strFileName = objFile.Readline
    objFSO.CopyFile strCopyFrom & "\" & strFileName & ".*", strCopyTo
Loop
 
objFile.Close

Open in new window

0
 

Author Closing Comment

by:MNAdmin
ID: 31517464
Thank you Shift
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question