AutoHotkey Community

It is currently May 27th, 2012, 4:14 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: February 17th, 2010, 5:34 pm 
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)


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2010, 5:46 pm 
Offline

Joined: June 6th, 2006, 3:19 pm
Posts: 1654
Location: Denmark
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2010, 5:57 pm 
Offline

Joined: April 19th, 2005, 10:26 am
Posts: 2249
Location: switzerland
... 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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 17th, 2010, 10:31 pm 
Offline

Joined: May 27th, 2007, 9:41 am
Posts: 4999
emmm Splitpath anyone
Code:
OutNameNoExt     Name of the variable in which to store the file name without its path, dot and extension.
http://www.autohotkey.com/docs/commands/SplitPath.htm

_________________
AHK FAQ
TF : Text files & strings lib, TF Forum


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2010, 7:51 am 
@tonne @garry:- thanks a lot for all your solutions its reallly working very sweetly hats off guys


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 18th, 2010, 7:52 am 
@tonne @garry:- thanks a lot for all your solutions its reallly working very sweetly hats off guys


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: rbrtryn and 65 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group