|
|
#1 |
|
Prospect
Join Date: Aug 2011
Posts: 2
|
Need help with script
Hey guys I have a list of serial numbers that start off with a "S" character that I need to remove with a script. The tricky thing is that I only need to remove the "S" that shows up second in the serial number. Does anyone have any ideas or a script that could help?
Thanks Example: Before script SER-NO SC02H706NDJGR SER-NO SC02H707PDJGR SER-NO SC02H708YDJGR SER-NO SC02H79TBDJGR After script SER-NO C02H706NDJGR SER-NO C02H707PDJGR SER-NO C02H708YDJGR SER-NO C02H79TBDJGR |
|
|
|
|
|
#2 | |||||||||||||||||||||||
|
Hall of Famer
Join Date: Oct 2002
Location: Halifax, Canada
Posts: 4,945
|
set BeforeScript to {"SER-NO SC02H706NDJGR", "SER-NO SC02H706NDJGR", "SER-NO SC02H708YDJGR", "SER-NO SC02H79TBDJGR"}
__________________
17" MBP, OS X 10.8.3; 27" iMac, OS X 10.8.3 Last edited by NovaScotian; 08-09-2012 at 04:51 PM. |
|||||||||||||||||||||||
|
|
|
|
|
#3 |
|
Major Leaguer
Join Date: Apr 2010
Posts: 324
|
Assuming you have a file containing those serial numbers you want to convert (and only those serial numbers you want to convert)...
Code:
set listSerialNums to paragraphs of (read (choose file)) set numFileIdNewSerialNums to open for access ((path to desktop folder as string) & "corrected serial numbers" & space & (random number from 1 to 1000) & ".txt") with write permission repeat with textSerialNum in listSerialNums if textSerialNum ≠ "" then set textCorrectedSerialNum to text 2 thru -1 of (word 3 of textSerialNum) write (textCorrectedSerialNum & return) to numFileIdNewSerialNums as text end if end repeat close access numFileIdNewSerialNums
__________________
see a problem; solve a problem. |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|