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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newb Scripter In Need of Help!

Status
Not open for further replies.

LibertyGuy

Technical User
Feb 26, 2008
28
US
Hello,
I'm a complete newb at scripting, as in this is my first time ever even attempting it. I've been tasked with (as busy work more or less) creating a vb script that will list the folders inside a "ready to archive" folder, create a csv file, and move the files to a designated folder.

So far this is all I have:

directoryname="\\server\LCS_2\ --THESE CAN ARCHIVE"
Set fso = CreateObject("Scripting.FileSystemObject")
set mainfolder=fso.GetFolder("\\server\LCS_2\ --THESE CAN ARCHIVE")
Set foldercollection = mainfolder.SubFolders
For Each folder In foldercollection
Wscript.Echo folder.Name
Next

Even this little bit required some expert advice, as like I said I am a complete beginner with all of this. At any rate, what I have so far is doing what it should; it is listing the contents of said folder. However, I want to filter out folders that start with a period (hidden folders), and I would like for these folders to be ignored altogether.

Any advice is much appreciated with moving these folders and creating a text file of the listing before the move. Please remember that I am not too savvy with this so if you could explain in the most dumb-downed version possible I would be forever greatful.

Thank you!

 
Do you have to use vbscript. Whats wrong with just using a DOS tool like xcopy

xcopy /L /Y /C /S 'source_dir' displays folders/files in source_dir that would be copied but doesn't actually copy them. Hidden files/folders by default are not copied. Redirect this command to file and you have your list of files albeit not in CSV format. Repeat the same command (sans redirection) without the /L flag and the actual copying would be done.




In order to understand recursion, you must first understand recursion.
 
I am not trying to use xcopy. I am trying to learn some vbscript. Also, if I wasn't trying to get the information exported to CSV format I would not have specifically mentioned CSV. This does not help me at all. Furthermore, I don't even understand half the things you are talking about.

I'll repeat myself: I am a 100% beginner, as in this is my first look at this kind of stuff EVER. Period. I don't know anything about /L /Y/ /C /S or what any of that means, and since they are irrelevent to my question, I don't really care.
 
filter out folders that start with a period
Code:
For Each folder In foldercollection
  If Left(folder.Name, 1) <> "." Then
    Wscript.Echo folder.Path
  End If
Next

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you PHV. Now, how would I generate a csv of this output, and go about moving those folders to a new location to be archived?

Thank you again for your assistance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top