| View previous topic :: View next topic |
| Author |
Message |
lost world Guest
|
Posted: Wed Feb 17, 2010 4:34 pm Post subject: retrieving a text from a file path |
|
|
hi...how to retrieve xyz from the following path
C:\Documents and Settings\lostworld\Desktop\xyz.txt
well i read all string commands and i can work through specifying count or getpos.....but is their a way to detect last '\' ? so that anything after that can be retrieved in this case xyz.txt
if this is possible then is it possible now to get only xyz (excluding .txt) |
|
| Back to top |
|
 |
tonne
Joined: 06 Jun 2006 Posts: 1651 Location: Denmark
|
Posted: Wed Feb 17, 2010 4:46 pm Post subject: |
|
|
| Code: | path := "C:\Documents and Settings\lostworld\Desktop\xyz.txt"
pos := instr(path,"\", false, 0) ; 0 search backwards
msgbox % substr(path,pos+1) ; +1 skip \
|
_________________ RegEx Powered Dynamic Hotstrings
COM
AutoHotkey 2 |
|
| Back to top |
|
 |
garry
Joined: 19 Apr 2005 Posts: 2214 Location: switzerland
|
Posted: Wed Feb 17, 2010 4:57 pm Post subject: |
|
|
... get only xyz
| Code: | F1=C:\Documents and Settings\lostworld\Desktop\xyz.txt
SplitPath,F1, name, dir, ext, name_no_ext, drive
msgbox,%name_no_ext%
return
|
or example go back (2)
| Code: | F1=C:\Documents and Settings\lostworld\Desktop\xyz.txt
StringSplit,CX, F1,`\
X=2 ;-- minus 2 goback
C:=(CX0-X)
loop,%c%
E =% E . CX%A_Index% . "\"
msgbox,C=%c%`nE=%E% ;-- (3) C:\Documents and Settings\lostworld\
return
|
|
|
| Back to top |
|
 |
SoLong&Thx4AllTheFish
Joined: 27 May 2007 Posts: 4999
|
|
| Back to top |
|
 |
Guest
|
Posted: Thu Feb 18, 2010 6:51 am Post subject: |
|
|
| @tonne @garry:- thanks a lot for all your solutions its reallly working very sweetly hats off guys |
|
| Back to top |
|
 |
lostworld Guest
|
Posted: Thu Feb 18, 2010 6:52 am Post subject: |
|
|
| @tonne @garry:- thanks a lot for all your solutions its reallly working very sweetly hats off guys |
|
| Back to top |
|
 |
|