1.

Solve : Help needed.. batch commands?

Answer»

Hi Gurus,

I have checked few posts and found this forum interesting. I am new to batch commands and not have much experience.

Can you help me for below requirement,

I need to copy text from one txt file to TARGET txt file in specific way as below,
- I want to skip the first line (don't want to copy header)
- also can this be done in loop so that all the files in folder are read (example: 3-4 files) and the text from these files is appended to target txt file ?

any suggestions or commands to use..welcome!!

THANKS,
DD
you would probably want an xcopy if there all in the same place. If not it be copy Driveletter:\were it is Driveletter:\Were you want it, I dont follow unless these arent notepad doc's there will be need for more code. I assume that its a doc file, I can only aid this far sorry.you need to simply use copy, for, skip option in for and i think thats all Quote from: squall_01 on May 26, 2009, 08:20:21 AM

you would probably want an xcopy if there all in the same place. If not it be copy Driveletter:\were it is Driveletter:\Were you want it, I dont follow unless these arent notepad doc's there will be need for more code. I assume that its a doc file, I can only aid this far sorry.

kayHi,
Thanks for your reply..

It is not doc file.

Example:
File1.txt :
PersonNo Name
1001 Alex
1002 Mac

File2.txt :
PersonNo Name
1003 Jack
1004 Nick

Target.txt : The file where text from File1 & File2 to be copied

After copy the the target file shoul looks as below
Target.txt
PersonNo Name
1001 Alex
1002 Mac
1003 Jack
1004 Nick

Is it possible ?

Regards,
DD

i seems to have a batch script to suit your work, i wrote it in the early days when i LEARN scripting, and it's messy code all around, but i've been using it in daily basis until TODAY and too lazy to clean-up the code. when noob like me write a batch code, there is a lot of unnecessary goto and label that i first think it is cool to modulize the coding into function and procedure in OOP TERM.
download the attached batch file.

how to use:
Code: [Select]D:\batch>concat /?

USAGE: concat [SOURCE DIRECTORY] [OUTPUT FILE] [HEADERLINENUMBER] [CUSTOMHEADER]

D:\batch>concat ?.doc target.txt 1
target.txt not exist

done 1.doc = 2 Line(s)
done 2.doc = 2 Line(s)
Total Files=2 File(s)

D:\batch>type target.txt
PersonNo Name
1001 Alex
1002 Mac
1003 Jack
1004 Nick
[attachment deleted by admin]thanks for the aid, hope this all pains out I was thinking of linux abit sorry there so close to being the same.


Discussion

No Comment Found