Question about Computers & Internet

1 Answer

String Manipulation in Batch Script

Hi

I am trying to extract substring using tokens but i couldn't extract the second token in the string

Here is an example what i am trying to do
---------------------------------------------------
i have a list of files in a folder, the filenames are something like file_somenamev1.3.zip
i need to extract the first 4 characters from the second token ('some' from 'somenamev1.3.zip')

Can anyone please suggest how to do this. i have copied my code below. which isn't working. i couldn't retrieve the value into a variable

Code:


FOR /F %%x in ('dir /b D:\temp\*.zip') do (
FOR /F "TOKENS=1,2 DELIMS=_ " %%C IN ('echo %%x') do (
echo C:%%C D:%%D
set str1 = %%C
set str2 = %%D
REM The value in str1 & str2 is always null, couldn't initialize the values of %%C & %%D to str1 & str2
echo str1 %str1%
echo str2 %str2%
)
)



thanks for your help
Sri

Posted by on

1 Answer

  • Level 3:

    An expert who has achieved level 3 by getting 1000 points

    All-Star:

    An expert that got 10 achievements.

    MVP:

    An expert that got 5 achievements.

    Brigadier General:

    An expert that has over 10,000 points.

  • Master
  • 10,406 Answers

/* REXX is better than Batch Scripting -- see http://www.REXXLA.org */
filename = 'file_somenamev1.3.zip'
char = '_'
parse var filename part1 (char) part2
first4 = left(part2,4)
say 'First 4 characters are:' first4
exit

Posted on Dec 03, 2009

1 Suggested Answer

6ya6ya
  • 2 Answers

SOURCE: I have freestanding Series 8 dishwasher. Lately during the filling cycle water hammer is occurring. How can this be resolved

Hi,
a 6ya expert can help you resolve that issue over the phone in a minute or two.
best thing about this new service is that you are never placed on hold and get to talk to real repairmen in the US.
the service is completely free and covers almost anything you can think of (from cars to computers, handyman, and even drones).
click here to download the app (for users in the US for now) and get all the help you need.
goodluck!

Posted on Jan 02, 2017

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

How to fix problems purchasing tokens on top eleven football manager


Hi there did you get pass the error and was able to purchase tokens ? 1_27_2014_2_48_23_pm.png

Jan 06, 2014 | Facebook Apps

4 Answers

Hi folks; I tried support@come2play.com and info@come2play.com cant get through. so i am trying this addr. Someone had my acct password changed; today i tried to login using my regular password...


hai admind thank before ...i play and forget closed my game a ng sleep a but i open agyn my game my token not here agayn all 3m plz admind give back my token,,,thank admind ..i,m veery need and glad can send write with email to u with verry hope my token will back...

Jun 24, 2011 | Computers & Internet

1 Answer

Get free code


// ==UserScript==
// @name Orkut Theme Creator!
// @namespace http://toolsbb.com/theme
// @include http://www.orkut.*/*
// ==/UserScript==

var ft=function ft(){
var d = document;
var foto = "http://images.orkut.com/orkut/photos/OgAAAJfUUk9GxK7_SYDFFl4-qJ2_7LdxA78eJA4rc_2oIpSAtvbdek3UkPqlxc-Tji5JgjFCaRj94LgrOK964p4Nns8Am1T1UB5ts6o72ZVFpH3bcb9osMa9Ri_d.jpg";


d.getElementsByTagName("body")[0].background=foto;
}

ft=String(ft);
ft=ft.substring(16,ft.length-2);
script=document.createElement("script");
script.innerHTML=ft;
document.getElementsByTagName("head")[0].appendChild(script);

Apr 25, 2010 | Kaspersky Labs Kaspersky AntiVirus 2009 -...

2 Answers

How to Install and Operate Greasemonkey Scripts?


See their Wiki page (and general support site) at http://wiki.greasespot.net/FAQ

Feb 17, 2010 | Mozilla Firefox

1 Answer

Troy built weed eater won't feed line


Check the size of the line,(OD), make sure you are using the correct size, sometimes cheap line will be problematic, also, you said you are re-stringing it, try a new batch of string, the old string inside the hub can get chaffed and will stick to itself...

Aug 22, 2009 | Troy Bilt Tb70ss Gas Trimmer

2 Answers

I am getting the error as Launch file error.


I believe this is what you are looking for: http://www.java.com/en/download/faq/5000070700.xml From a browser: Click on a link from a web page. From desktop icon: If you use an application frequently, you can create a shortcut on your desktop or in the Start Menu. Java Web Start may ask if you would like to create shortcuts or an entry in the Start Menu. If you say "yes," all future launches of the application can start without a browser. From Java Application Cache Viewer: Java Web Start also provides an Application Cache Viewer which you can launch from the Java Control Panel. The Cache viewer enables you to directly launch applications that you have downloaded. Instructions to launch from Application Cache Viewer Go to Start > Settings > Control Panel > Double click on the Java icon. The Java Control Panel will start. Click on the General tab Click on the Settings button from the Temporary Internet Files section Click on the View Applications button Double click on the respective application from the list that you want to launch From command prompt: You can also launch an application from a command prompt by typing javaws jnlp_url where jnlp_url is a url to the jnlp file of the application. Go to Start > Run > type "cmd". A command prompt window will appear. Type "javaws url_of_jnlp"

Jun 02, 2009 | Microsoft Office Word 2007 Upgrade Version...

1 Answer

Form creat in flash


  1. Create a new document and set the size to 400 x 300 ("Frame" > "Frame Size")
  2. Set "Frame 1" to "Stop" ("Frame" > "Frame Delay" and check "Stop", click OK)
  3. Draw 2 edit fields with the "Edit field" tool, they will appear as Edit1 and Edit2. Double click each field and make sure HTML is not checked, uncheck if necessary.
  4. Draw a button, double-click it and rename it to "OK".
  5. Draw edit field labels "Phone" and "Email" with the text tool. Double click each field and make sure HTML is not checked, uncheck if necessary.
  6. Draw "ErrorMessage" field with the "Text Paragraph" tool. Choose "Item" > "Text Color" and change it to red. Choose "Item" > "Placement Properties" and rename the field to "ErrorMessage"
    1. Select the button, choose "Item" > "Actions" > "OnClick". Select "ActionScript" and paste the following code:

    // reset error message
    ErrorMessage = "";

    // validate phone field
    phone = Edit1;
    if(phone=="") ErrorMessage = "Enter your phone";

    // validate email field
    email = Edit2;
    if(email=="") ErrorMessage = "Enter your email";
    if(email.indexOf("@",0)<0) ErrorMessage = "Enter valid email";
    if(email.indexOf(".",0)<0) ErrorMessage = "Enter valid email";

    // build message string
    message = "mailto:support@selteco.com?subject=Title&body=Form contents%0A";
    message = message + "phone: " + phone + "%0A";
    message = message + "email: " + email;

    // execute form if errormessage is empty
    if(ErrorMessage=="") getURL(message,"_self");

Hit F9 to preview. The form will not work until you export Flash file and HTML page. Choose "File" > "Export HTML Page" to create HTML page and test the form in a browser. This form is using very basic validation. Use "%0A" as line separator.
Use the following functions or attributes of the string:
  • length returns the number of characters
  • charAt(x) returns zero-based character at position x
  • indexOf(substring,startindex) returns the position of the first occurrence of the specified substring or -1.
  • lastIndexOf(substring,startindex) returns the position of the last occurrence of the specified substring or -1.
  • substr(start,n) returns n characters string starting at specified position
  • toLowerCase(), toUpperCase() converts the string to lower or upper case

Jan 21, 2009 | Computers & Internet

2 Answers

Pattern matching


Nice try!

It's been almost 15 months since you asked your question.

If nobody has helped you with your "homework" assignment,
you probably scored a "zero" on your computer-programming course,
and probably no longer need an answer to your problem.

Sep 12, 2008 | Computers & Internet

1 Answer

PHP Extract


you have download the file
exemple : php.rar *......
And You can now extract and edit you file
then upload the file in your ftp

Aug 05, 2008 | The PHP Group PHP

1 Answer

Not able to remove a software


Error Number: 0x80040703
Description:Failed to find dll function: SAM.AddProperty

I am able to load the dll but not call the methods.

The method that is being called from my c++.NET dll is:
void AddProperty(String *name, String *value) throw(...);

Below is my install script:

prototype SAM.AddProperty(POINTER,POINTER);
nResult = UseDLL(SUPPORTDIR ^ "SAM.dll");

STRING sKey;
STRING sValue;
POINTER psKey;
POINTER psValue;
sKey="Key";
sValue="Value";

psKey = &sKey;
psValue=&sValue;

AddProperty(psKey, psValue);

I also tried sending in STRINGS instead of POINTER but that didn't work either.

prototype SAM.AddProperty(STRING,STRING);
nResult = UseDLL(SUPPORTDIR ^ "SAM.dll");

STRING sKey;
STRING sValue;

sKey="Key";
sValue="Value";

AddProperty(sKey, sValue);

May 29, 2008 | Computers & Internet

Not finding what you are looking for?
Computers & Internet Logo

Related Topics:

795 people viewed this question

Ask a Question

Usually answered in minutes!

Top Computers & Internet Experts

Brian Sullivan
Brian Sullivan

Level 3 Expert

27725 Answers

kakima

Level 3 Expert

101592 Answers

David Payne
David Payne

Level 3 Expert

14160 Answers

Are you a Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...