Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 7th, 2011, 06:00 PM
sunnie_joe sunnie_joe is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 4 sunnie_joe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 30 m 48 sec
Reputation Power: 0
Read line of text and create files

Using Windows XP and Windows 7

I would like to create files from each line of text reading from textfile.txt and put the files in a directory c:\myfiles\

Here’s what I have
The content of Textfile.txt file is as follow;

Hello Joe
Good morning
Yesterday was the first
Today the 2nd
Tomorrow the 5th

When I run the script I like to end up with;

C:\myfiles\Hello Joe.txt
C:\myfiles\Good morning.txt
C:\myfiles\Yesterday was the first.txt
C:\myfiles\Today the 2nd.txt
C:\myfiles\Tomorrow the 5th .txt

Thanks in advance..

Reply With Quote
  #2  
Old November 7th, 2011, 08:46 PM
anziga anziga is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 189 anziga User rank is Major (30000 - 40000 Reputation Level)anziga User rank is Major (30000 - 40000 Reputation Level)anziga User rank is Major (30000 - 40000 Reputation Level)anziga User rank is Major (30000 - 40000 Reputation Level)anziga User rank is Major (30000 - 40000 Reputation Level)anziga User rank is Major (30000 - 40000 Reputation Level)anziga User rank is Major (30000 - 40000 Reputation Level)anziga User rank is Major (30000 - 40000 Reputation Level)anziga User rank is Major (30000 - 40000 Reputation Level)anziga User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 12 h 34 m 58 sec
Reputation Power: 327
Sounds a bit like a homework... but google how to read text files, how to write text files and how to make a loop. Once you have put something together and if it doesn't work, place the code here together with possible error message(s) and somebody will definitely help you. But you have to be a bit more initiative than that, not sure if somebody here is willing to hand over the code or do your homework for you.

Reply With Quote
  #3  
Old November 8th, 2011, 08:11 AM
sunnie_joe sunnie_joe is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 4 sunnie_joe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 30 m 48 sec
Reputation Power: 0
Smile

Thanks for taking the time and feedback. No it’s not a homework! LOL.. it’s related to movie library I’m putting together and this is one part of it. I been experiment with batch files and command line.. the closest one I came across work partially but it was intended to work with existing files and not to create one from scratch!

I'm using a batch file (file.bat)

This is the command line in the batch file..

for /f "delims=" %%i in (filelist.txt) do echo D|xcopy "%%i" "c:\myfiles\%%i" /i /Z /y


This is what's happening when I run the batch file...


C:\myfiles>files.bat

C:\myfiles>for /F "delims=" %i in (filelist.txt) do echo D | xcopy "%i" "c:\myfiles\%i" /i /Z /y

C:\myfiles>echo D | xcopy "Hello Joe" "c:\myfiles\Hello Joe" /i /Z /y
File not found - Hello Joe
0 File(s) copied

C:\myfiles>echo D | xcopy "Good morning" "c:\myfiles\Good morning" /i /Z /y
File not found - Good morning
0 File(s) copied

C:\myfiles>echo D | xcopy "Yesterday was the first" "c:\myfiles\Yesterday was the first" /i /Z /y
File not found - Yesterday was the first
0 File(s) copied

C:\myfiles>echo D | xcopy "Today the 2nd" "c:\myfiles\Today the 2nd" /i /Z /y
File not found - Today the 2nd
0 File(s) copied

C:\myfiles>echo D | xcopy "Tomorrow the 5th" "c:\myfiles\Tomorrow the 5th" /i /Z /y
File not found - Tomorrow the 5th
0 File(s) copied

C:\myfiles>

Hope this helps...

Reply With Quote
  #4  
Old November 8th, 2011, 05:25 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 19th Plane (14000 - 14499 posts)
 
Join Date: Jun 2003
Posts: 14,237 Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level)Doug G User rank is General 52nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 14 h 47 m 12 sec
Reputation Power: 4445
If there are spaces in the file name after it's expanded by your batch file, you need quotes around that filename. To do this you'd normally embed quotes by putting double quotes inside the quoted string. That's how it would work with vbscript, anyway, I'm not sure with batch files, this is a VB forum.
__________________
======
Doug G
======
It is a truism of American politics that no man who can win an election deserves to. --Trevanian, from the novel Shibumi

Reply With Quote
  #5  
Old November 8th, 2011, 06:11 PM
sunnie_joe sunnie_joe is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2007
Posts: 4 sunnie_joe User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 30 m 48 sec
Reputation Power: 0
Doug, I can live with VB script as long as the end results is right!
Thank you

Reply With Quote
  #6  
Old December 7th, 2011, 03:07 PM
the-listener the-listener is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2011
Posts: 23 the-listener User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 48 m 40 sec
Reputation Power: 0
dos vb scheebee

Quote:
Originally Posted by sunnie_joe
Doug, I can live with VB script as long as the end results is right!
Thank you


I like your attitude, anything that works will do...

a post after yours asks about capturing output from cmd

if you call your batch file you will be creating a number of calls to the system.

simply add >>filename.bat when calling your batch file and the result will show you exactly what you are creating without the problems associated with the creation.

this way you can build a better batchfile from the output file and debug your original batch file in the process

I often use a batch file and textfile combination to create the batch file that will actually do the work.

in light of this being a vb forum a vb thing can be supplied if needed


bill stewart - here to talk

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Read line of text and create files

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap