Specialty Forums
Security and Virus
General Hardware
CPUs/Overclocking
Networking
Digital Photo/Video
Office Software
PC Gaming
Console Gaming
Programming
Database
Web Development
Digital Home

General Forums
Windows XP
Windows Vista
Windows 95/98
Windows Me
Windows NT
Windows 2000
Win Server 2008
Win Server 2003
Windows 3.1
Linux
PDAs
BeOS
Novell Netware
OpenVMS
Solaris
Disk Op. System
Unix
Mac
OS/2

Drivers
Driver Scan
Driver Forum

Software
Automatic Updates

BIOS Updates

My Computing.Net

Solution Center

Free IT eBook

Howtos

Site Search

Message Find

RSS Feeds

Install Guides

Data Recovery

About

Home
Reply to Message Icon Go to Main Page Icon

random string with batch

Original Message
Name: frauhottelmann
Date: December 9, 2007 at 11:08:41 Pacific
Subject: random string with batch
OS: WinXP Prof. SP2
CPU/Ram: Athlon XP 3200+/0,75 Gb
Comment:
I need to get a random 16 character string from a txt file into a new txt file. The txt file looks like this:

---------- C:\FWID.TXT
"3"="USBSTOR\\Disk&Ven_Apple&Prod_iPod&Rev_1.62\\000A270018E6ED40&0"

And I need to get 000A270018E6ED40 which should always be located between the \ and the & (at least I hope so)! Right now it needs to be a DOS command, but if you have it in an easier way, feel free to post, I could switch later, but now PLEASE in DOS-commands.
I hope it`s not impossible, since it is necessary for ml_iPod!
Thanks anyway


Report Offensive Message For Removal


Response Number 1
Name: frauhottelmann
Date: December 9, 2007 at 11:33:44 Pacific
Subject: random string with batch
Reply: (edit)
Mh, you could also just cut off the characters before and after the string! This would actually be more helpful, since I need it for a second txt and in there the structure is different!

Report Offensive Follow Up For Removal

Response Number 2
Name: Razor2.3
Date: December 9, 2007 at 20:07:30 Pacific
Subject: random string with batch
Reply: (edit)
Untested:
FOR /F "tokens=6 delims=\^&" %a IN (FWID.TXT) DO @ECHO %a


Report Offensive Follow Up For Removal

Response Number 3
Name: frauhottelmann
Date: December 11, 2007 at 02:10:57 Pacific
Subject: random string with batch
Reply: (edit)
Yes it works, but how can I output that to a txt file?

Report Offensive Follow Up For Removal

Response Number 4
Name: tonysathre
Date: December 11, 2007 at 05:11:20 Pacific
Subject: random string with batch
Reply: (edit)

FOR /F "tokens=6 delims=\^&" %a IN (FWID.TXT) DO @ECHO %a >> file.txt

"Computer security." — Oxymoron


Report Offensive Follow Up For Removal

Response Number 5
Name: frauhottelmann
Date: December 11, 2007 at 09:46:41 Pacific
Subject: random string with batch
Reply: (edit)
It works when I use it from cmd, but when I write it into my batch, it doesn't. So right now it looks like this:
REGEDIT /E c:\fwid.txt HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Disk\Enum
find /I "iPod" c:\fwid.txt > c:\apple.txt
del C:\fwid.txt
FOR /F "tokens=6 delims=\^&" %a IN (C:\apple.TXT) DO @ECHO %a >> C:\file.txt

Report Offensive Follow Up For Removal


Response Number 6
Name: tonysathre
Date: December 11, 2007 at 12:04:42 Pacific
Subject: random string with batch
Reply: (edit)

@echo off
REGEDIT /E c:\fwid.txt HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Disk\Enum
find /I "iPod" c:\fwid.txt > c:\apple.txt
del C:\fwid.txt
FOR /F "tokens=6 delims=\^&" %%a IN (C:\apple.TXT) DO @ECHO %%a >> C:\file.txt

You must use double % signs in scripts.


"Computer security." — Oxymoron


Report Offensive Follow Up For Removal

Response Number 7
Name: frauhottelmann
Date: December 12, 2007 at 00:39:43 Pacific
Subject: random string with batch
Reply: (edit)
Oh, I didn't know this thank you very much!
Now I have a second question, for the iPod Touch, the registry string is different, so the code from above doesn't work.The txt looks like that (without the first and last "):
"
---------- C:\FWID.TXT
"1"="USB\\\\Vid_05ac&Pid_1290\\\\5299c8e84b07acce79299f9a83ed8806cb3800a8""
What I need are the first 16 characters after the \\\\, so in this case 5299c8e84b07acce .
Is that possible?
Oh and it is not necessarily a 1290 it can also be a 1291 before the \\\\

Report Offensive Follow Up For Removal

Response Number 8
Name: tonysathre
Date: December 12, 2007 at 05:16:50 Pacific
Subject: random string with batch
Reply: (edit)

@echo off
for /f "tokens=3 delims=\\\\" %%a in (file.txt) do (
set _=%%a
)
for /f "tokens=*" %%a in ('echo %_%') do (
set _=%_:~0,16%
)
echo %_%


"Computer security." — Oxymoron


Report Offensive Follow Up For Removal

Response Number 9
Name: frauhottelmann
Date: December 12, 2007 at 05:30:18 Pacific
Subject: random string with batch
Reply: (edit)
Hm somehow it doesn't work, this is my code right now (I had to double the last couple %:
@echo off
REGEDIT /E c:\fwid.txt HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBAAPL\Enum
find /I "Vid_05ac" c:\fwid.txt > c:\apple.txt
del C:\fwid.txt
for /f "tokens=3 delims=\\\\" %%a in (C:\apple.txt) do (set _=%%a)
for /f "tokens=*" %%a in ('echo %%_%%') do (set _=%%_:~0,16%%)
echo %%_%%
Pause

Report Offensive Follow Up For Removal

Response Number 10
Name: tonysathre
Date: December 12, 2007 at 06:37:58 Pacific
Subject: random string with batch
Reply: (edit)
There's no need to double those percent signs. What error are you getting? It worked fine for me.

I tested it using a text file containing this:

"1"="USB\\\\Vid_05ac&Pid_1290\\\\5299c8e84b07acce79299f9a83ed8806cb3800a8""

The output was 5299c8e84b07acce.

"Foolproof systems don't take into account the ingenuity of fools."


Report Offensive Follow Up For Removal

Response Number 11
Name: frauhottelmann
Date: December 12, 2007 at 06:42:04 Pacific
Subject: random string with batch
Reply: (edit)
I didn't get anything! The txt is an empty line and then:
---------- C:\FWID.TXT
"1"="USB\\\\Vid_05ac&Pid_1290\\\\5299c8e84b07acce79299f9a83ed8806cb3800a8"

When I let it run it just exits!


Report Offensive Follow Up For Removal

Response Number 12
Name: tonysathre
Date: December 12, 2007 at 10:33:20 Pacific
Subject: random string with batch
Reply: (edit)
Try this:


@echo off
for /f "tokens=3 delims=\\\\" %%a in (test.txt) do (
set _=%%a
)
set _=%_:~0,16%

echo %_%

I'm not sure why I used a second FOR loop in that other post. This works for me just fine, when the text file contains:

::==Start of test.txt

---------- C:\FWID.TXT
"1"="USB\\\\Vid_05ac&Pid_1290\\\\5299c8e84b07acce79299f9a83ed8806cb3800a8"
::==EOF

"Computer security." — Oxymoron


Report Offensive Follow Up For Removal

Response Number 13
Name: frauhottelmann
Date: December 12, 2007 at 11:10:38 Pacific
Subject: random string with batch
Reply: (edit)
Yeah this works great! Thank You very much! You helped ml_iPod a lot!

Report Offensive Follow Up For Removal



Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: random string with batch

Comments:

 
  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 


Data Recovery Software




DSHUB24 Connection Problems

need help with dsl and dial up

novel 3.12

help mandriva install last straw!

Icon Scaling in Explorer Bar


The information on Computing.Net is the opinions of its users. Such opinions may not be accurate and they are to be used at your own risk. Computing.Net cannot verify the validity of the statements made on this site. Computing.Net and Computing.Net, LLC hereby disclaim all responsibility and liability for the content of Computing.Net and its accuracy.
PLEASE READ THE FULL DISCLAIMER AND LEGAL TERMS BY CLICKING HERE

All content ©1996-2007 Computing.Net, LLC