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
252 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 51

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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
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 82

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 51

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

708 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

18 Experts available now in Live!

Get 1:1 Help Now