473,839 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need a Windows Script Host VBScript File that Moves a Text File...

1 New Member
...to a different folder and in the relocated file concatenates all of the lines in one long string with a space between each line element. Here is a fuller statement of the problem:

I need a Visual Basic Script file, call it "Move and Reformat Text File.VBS," that will run from a Windows Script Host command-prompt-based version as follows:

C:\> Cscript.exe "Move and Reformat Text File.VBS"

The objective of the VBScript file, "Move and Reformat Text File.VBS,” is to move a text file from an input folder, "C:\Input\, ” to an output folder, "C:\Output\ ,” but with all lines of the original file concatenated to a single string, and with a space inserted between the line elements.

For example, say, the input file is "C:\Input\1.TXT " and it contains the following lines:

Line_1
Line_2
. . .
Line_n

Then I want to create a corresponding output file "C:\Output\1.tx t" that contains a single line, i.e., one string, as follows:

Line_1 Line_2 . . . Line_n

Note the single space inserted between each line.

After this is done, delete the input file, "1.TXT " from the "C:\Input\" folder.

Do this procedure for each *.TXT file in the input folder.

Also, sense when a new text file is added to the "C:\Input\" folder and run the procedure again. Or, if it is not feasible to program that, then at least invoke "Move and Reformat Text File.VBS" periodically, say, every five minutes.

In summary, here is the pseudo code outline of the procedure I envision:

For each text file in the input folder
- Create a new, blank, output text file of the same name as the input file.
- Save the new output text file in the output folder.
- Concatenate all the lines of the input file to one string.
- Append the concatenated string in the new output text file.
- Close the output text file.
- Delete the input text file.

Thanks for your help.
Jan 4 '07 #1
1 4783
Killer42
8,435 Recognized Expert Expert
This would be pretty simple to do in straight VB, but don't think I've ever written a VBS.

However, I think Windows Scheduled Tasks will provide the "run every five minutes" functionality if you need it. If this were straight VB6 code, I would either use a timer control to wake up every however-often and scan the directory for new files. You could also have the program do an infinite loop executing a DoEvents statement and watch the folder for new files. Probably better to keep an eye on the time, and only check periodically; you might slow other processes down if you keep hammering the directory a hundred times a second.
Jan 4 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
4856
by: John Benson | last post by:
Hi, I'm in a tightly-secured environment where I may not be allowed to use Python for some scripting work, and may have to fall back on what came with Windows 2K. I'm cracking "VBScript in a Nutshell" from O'Reilly, and have found a number of disappointments: * can't find "Introspection" in the Index * no record types, just numerically-indexed arrays, so record handling is kludgy
1
3341
by: MSDN Account | last post by:
We have web site that used the IIS ResKit tool MSWC.PermissionChecker to check file permissions. The web site has been upgraded and that upgrade included changing the default server side language from VBScript to C# (*.vbs --> *.cs). Does C# have a native method for doing what MSWC.PermissionChecker used to do? If so has anyone gone through converting the MSWC.PermissionChecker method to C# and would they share what they did? If not...
3
6292
by: Angus Comber | last post by:
Hello Can javascript call/reference COM object. VBScript can do this (as it is from Microsoft). Can javascript? If so how? Angus
7
5332
by: unacoder | last post by:
Is it possible to request the user's permission to be able to control IE or FireFox windows that are pointed to domains other than the base domain the script is running from? For example, if my page launches a new window pointing to a web site originating from a different domain, is it possible for my script to request and gain access to the content of that window, and be able to control the window?
1
1569
by: pmarisole | last post by:
I need help in calculating a score from a row of drop-down values. I need to use the onChange to tally the score as the user moves across 9 categories (with drop-down selection of 1-9 or N/A) multiplied by a weighted score. The final column for each employee would be the calculated score. I know how to accomplish this with vbscript but I need it to process on the screen so the user can see the calculated score as they make selections....
19
3831
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function myFunc(val1ok, val2ok) ' do something ok myFunc = " return something ok" End Function </script>
1
8009
by: niveknornev | last post by:
Anyone ever used a script to create RDP session files? You can edit an RDP file using any text editor, however if you try to use simple batch, or vbscript to append text to that file, it doesn't retain it normal properties. Hopefully this example will make sense. I have 300 servers. I have a file with all their names/or/IPs in it. I wanted to create a batch file or vbscript that would run through that list and create files named...
0
9972
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: Programs dealing with autoruns Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list programs that help me to view/modify the autoruns on my Windows PC? Ans: Other than Sysinternals Autoruns, there are only a few programs which are good enough to be used when dealing with autoruns. For more information about Sysinternals Autoruns, read Que-7 in Windows Autorun FAQs: Description....
0
9856
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10914
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10656
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7834
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5684
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4495
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3136
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.