Link to home
Start Free TrialLog in
Avatar of Axis52401
Axis52401Flag for United States of America

asked on

How to automatically edit a text file to add a command space and then move the below line up to after the space

We use a scanner to scan bar codes when we get in inventory. The Inventory system is web bases so all we have to do is type in that number into a text box or several numbers and it will update the file with all the item. The problem is that the scanner outputs the serial numbers like this (below)

00020957000311
00020957000311
16139651541515
etc

When we put them into the browser to do it to enter multiple items we have to change it to

00020957000311, 00020957000311, 16139651541515...etc

Basically we have to take the list and hit comma space delete so they line up like that so the S/W can upload multiple serial numbers. The problem is this list can be 500 serial numbers long and ir rather tedious. Is there any sort of script or Macro that can do this from the list?
 
Avatar of nutsch
nutsch
Flag of United States of America image

by hand, you can put your numbers in column A, put this in B1 =A1, and in B2 put =B1&","&a2 and copy down b2 all the way down. The last B will be the result you need.

Thomas
By macro, you can put your numbers in column A and run the attached code

sub concat
dim cl as range, strResult as string

for each cl in range(cells(1,1),cells(rows.count,1).end(xlup))
strresult=strresult & cl &","
next cl

strresult=left(strresult,len(strresult)-1)

cells(1,2)=strresult

end sub

Open in new window

Avatar of Bill Prew
Bill Prew

If you want to do it in a BAt script, you can do the following:

@echo off
if exist "c:\temp\output.txt" del "c:\temp\output.txt"
for /F "tokens=*" %%A in ("c:\temp\input.txt") do (
  echo.%%~A>>"c:\temp\output.txt"
)

Open in new window

~bp
Avatar of Axis52401

ASKER

I was hoping there was some sort of Utility I could use, I'm bot much of a programer.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
oBda, wow, I was dozing when I created that, wasn't I !
Thanks, that worked perfectly