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

Complete Beginner In Need Of Assistance 1

Status
Not open for further replies.

LibertyGuy

Technical User
Feb 26, 2008
28
US
Hi everyone,

I've never done any amount of programming or scripting in my life, but apparently at my job, the PC Support Specialist(Me) does the scripting...

Anyway, I've been tasked with creating a script to run on one of our servers that will do the following

1) List files (folder contents)
2) Create text file(csv) of this information
3) Move the files to a designated location, I'm assuming to our sql database

I am clueless as I've never done any of this before. I realize for you pros that this is probably pretty simple and most likely a dumb question, but I have very limited resources and It's frustrating that this has been given to me when I clearly was not hired for tasks such as this. Any/all suggestions are more than appreciated.
 
The good news is that you are in the perfect position to learn scripting. Having a specific task to perform is a great way to start. But first I suggest you arm yourself with a couple of books as a point of reference.

Search this forum for books on scripting and you will get some good suggestions.

I personally recommend O'Reilly's "VBScript In a Nutshell". This is great desktop reference that will help you read scripts that you find on the internet. It won't teach you to program, it is strictly a syntax reference.

There are 1000s of sample scripts on the internet. Include the term "vbscript" in your searches.

Next... Check out the FAQ section of this forum as it has quite a few very useful scripts that you can modify for your own purposes.

Now... As to your question... Is there an existing script that you are supposed to update? What has already been done in your environment that can give you a starting point?



PSC

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
So far all I'm trying to get going is the file listing in the directory. So far I've only gotten this much and it doesn't seem to work. It says Expected: 'Response'


directoryname="\\lcs-server\LCS_2\ --THESE CAN ARCHIVE"
Set fso = CreateObject("Scripting.FileSystemObject")
set mainfolder=fso.GetFolder("\\lcs-server\LCS_2\ --THESE CAN ARCHIVE")
Set filecollection = mainfolder.Files
For Each file In filecollection
Response.Write file.Name
Next

^^What's wrong here?
 
Are you doing this as an ASP page? If you are running this as a stand alone VBScript, then use WScript.Echo instead of Response.Write.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Ahh, thanks for that. It stopped the error from showing up, but it only shows names for about 2 files and I know there are more than that. Also, I have many subfolders that I wish to be included.

And also, why does it show the filenames 1 at a time? You click OK and it shows you the next one. How can I have it write it to a text file and open it in a window?

Thanks for all the help so far!!
 
When you are working on the script and you will probably will generate a lot of output, run the script using cscript.exe explicitly at the command line.



[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top