User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Shell Scripting section within the Software Development category of DaniWeb, a massive community of 397,616 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,398 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Shell Scripting advertiser:
Views: 367 | Replies: 1
Reply
Join Date: Jul 2008
Posts: 1
Reputation: leshi is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
leshi leshi is offline Offline
Newbie Poster

.bat need help with this simple command

  #1  
Jul 21st, 2008
This code , which is basically created "createdtxt.txt" text file that writes each files location
dir /s/b D:\mypictures\*.JPG >createdtxt.txt
would give me a file createdtxt.txt with these lines
D:\mypictures\DSC07861.JPG
D:\mypictures\DSC07870.JPG
D:\mypictures\DSC07871.JPG

HOW can i add simple command into this code that would give the name John before each line example:

John D:\mypictures\DSC07861.JPG
John D:\mypictures\DSC07870.JPG
John D:\mypictures\DSC07871.JPG
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2007
Posts: 264
Reputation: eggi is on a distinguished road 
Rep Power: 1
Solved Threads: 26
eggi eggi is offline Offline
Posting Whiz in Training

Re: .bat need help with this simple command

  #2  
Jul 22nd, 2008
Hey There,

I'm not sure if this is the right forum for this question, but I think it is, so apologies to the mods if I'm answering something I shouldn't be.

You can do a for loop in windows bat files like this:

Format is:

for %VAR in (REGULAR_EXPRESSION) do WHATEVERYOUWANTTOTHEREGEXP

for %x in (*LOG*) do echo JOHN dir %x >> BOG.LOG

Obviously, just change it to suit your needs.

Best wishes,

Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
Having trouble passing cert exams? Check out How To Pass Any Computer Certification Test!
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Shell Scripting Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Shell Scripting Forum

All times are GMT -4. The time now is 8:07 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC