![]() |
| |||||||
Automation Anywhere Post messages and questions related to Automation Software here. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| |||
|
Hello, You can easily leverage functionality of Excel to automate your task. You can use Mid() function of excel to extract the characters from a text string, given a starting position and length. We have also attached a sample task (Last3Char.atmn) for your convenience. Copy it under location: My Documents\Automation Anywhere\Automation Anywhere\My Tasks. You can make changes in it according to your requirement for e.g. instead of ‘001-002345-ABC’ you can use filename also, you can run this task directly. Hope that helps. |
| |||
|
Windows batch scripts can do simple string manipulation for you without the need to run (or buy and install) a large program like Excel. Depending on how you want to interface with this data, this method may be useful. Below is a screen capture showing a small sample of what you can do quickly and easily with batch scripts. You just need to be able to access the output of the command-line "echo." statements or redirect the output of the echo statements to a file using the syntax echo.your text here >filename The lines that start with c:\testdirectory> show what I typed in (I typed the stuff that comes after the '>'). The lines immediately following my commands are the returned values. Here's the screen cap: c:\testdirectory>set avariablename=001-002345-ABC.TIF c:\testdirectory>echo.%avariablename:~-3% TIF c:\testdirectory>echo.%avariablename:~1,-3% 01-002345-ABC. c:\testdirectory>echo.%avariablename:~1,-4% 01-002345-ABC ************************************************** *** Here's a slightly more sophisticated approach that does more to show off the possibilities than anything else. I'm going to write a short program on the fly. The funny thing is that creating a whole program to do the work for you, then running it and deleting it is still faster than opening Excel. By the way, the ^Z is control+Z. ************************************************** *** c:\testdirectory>copy con shortprog.bat @ECHO OFF echo.%~p1 is the path echo.%~n1 is the name echo.%~x1 is the extension echo.%~n1%~x1 is the name plus the extension echo.type "for /?" at the command prompt for more information ^Z 1 file(s) copied. ************************************************** *** So I just created a file that is also a program, and I did it all with keystrokes. Now I'll run the program, passing in our variable "variablename". When you want the value of a variable, enclose that variable's name in %s The "@ECHO OFF" suppresses my actual commands from being echoed to the screen, so that only the output of the commands shows. ************************************************** *** c:\testdirectory>shortprog %avariablename% \testdirectory\ is the path 001-002345-ABC is the name .TIF is the extension 001-002345-ABC.TIF is the name plus the extension type "for /?" at the command prompt for more information c:\Documents and Settings\helpermonkey> ************************************************** *** In short, if you open a cmd.exe window and send these two commands: set tempstr=thestringyouwanttochop echo.%tempstr:~1,-4% the resulting text will be echoed to the screen for you to capture. Personally, I would advocate the approach where you make a small batch program on the fly (shortprog.bat), because that way Windows determines what the extension is and can remove it for you, whether the extension is exactly three letters or not. It runs very quickly, and its a good alternative if you want to run it on a PC that doesn't have Excel installed. Hope this helps! |
![]() |
| Thread Tools | |
| Display Modes | |
| |