Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
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
Medium Priority
?
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 58

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 85

Accepted Solution

by:
oBdA earned 2000 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 58

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

609 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