Solved

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

Posted on 2011-03-11
7
253 Views
Last Modified: 2012-05-11
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?
 
0
Comment
Question by:Axis52401
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 39

Expert Comment

by:nutsch
ID: 35113307
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
0
 
LVL 39

Expert Comment

by:nutsch
ID: 35113320
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

0
 
LVL 52

Expert Comment

by:Bill Prew
ID: 35113670
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
0
Why spend so long doing email signature updates?

Do you spend loads of your time carrying out email signature updates? Not very interesting are they? Don’t let signature updates get you down. Let Exclaimer Cloud - Signatures for Office 365 make managing email signatures a breeze.

 
LVL 2

Author Comment

by:Axis52401
ID: 35116143
I was hoping there was some sort of Utility I could use, I'm bot much of a programer.

Thanks
0
 
LVL 83

Accepted Solution

by:
oBdA earned 500 total points
ID: 35117283
Assuming you have those serials in a plain text file, try the batch script below. Save it as Whatever.cmd, then simply use Explorer to drag the serial text file on the batch script. It will create a new file with the same name as the serial file, but the extension ".out" (you can change that in line 4 if you want to). It will then open the new file in notepad, so you can copy and paste it from there.
@echo off
setlocal enabledelayedexpansion
set InFile=%~1
set OutFile=%~dpn1.out
if exist "%OutFile%" del "%OutFile%"
set Delim=
for /f "tokens=*" %%a in ('type "%InFile%"') do (
  (<NUL set /p Dummy=!Delim!%%~a)>>"%OutFile%"
  set "Delim=, "
)
start "" notepad.exe "%OutFile%"

Open in new window


billprew,
sorry, but that script won't work. To start with, it will only process the string "c:\temp\input.txt", not the file content, and even with that corrected, it will create another file with one serial per line, not one long line with comma separated serials.
0
 
LVL 52

Expert Comment

by:Bill Prew
ID: 35118087
oBda, wow, I was dozing when I created that, wasn't I !
0
 
LVL 2

Author Closing Comment

by:Axis52401
ID: 35172767
Thanks, that worked perfectly
0

Featured Post

Free book by J.Peter Bruzzese, Microsoft MVP

Are you using Office 365? Trying to set up email signatures but you’re struggling with transport rules and connectors? Let renowned Microsoft MVP J.Peter Bruzzese show you how in this exclusive e-book on Office 365 email signatures. Better yet, it’s free!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently Microsoft released a brand new function called CONCAT. It's supposed to replace its predecessor CONCATENATE. But how does it work? And what's new? In this article, we take a closer look at all of this - we even included an exercise file for…
This is an article about Leadership and accepting and adapting to new challenges. It focuses mostly on upgrading to Windows 10.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now