Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
getpath command
#1
I use getpath command to get the path of an executable file. Works great.

Problem I am having is that on this path, I need to add a folder and that isn't working too well for me.

Assumming the path is c:\windows\temp, I need to add "Current\*.*" so the new path would be c:\windows\temp\current\*.*. How do I do this?

Cry
#2
Code:
Copy      Help
str s1 s2 s3
s1="c:\windows\temp"
s2="current\*.*"
s3.from(s1 "\" s2)
out s3
#3
Oh works great! Didn't know about the "from" command. Kinda works like concat on other languages.

Thanks so much
#4
im trying to get the full path of a file with out knowing what hard drive it could be on lets say i want to find test.exe and have it "OUT" that in the output box
#5
?:\path\test.exe

You don't know drive letter (red). Do you know path without drive letter (green)? If no, searching for test.exe may take long time.
#6
its going to be either C or D drive ........ i guess what i need to do is a search to get the full path of the file, but im not sure how to do this with quick macros ...........just for an ex could you show me how i would search the C drive for a file to get the full path
#7
Function FindFileInDrives
Code:
Copy      Help
;/
function# $filename str&sPath [$drives] [driveType] [flags] [DATE'date1] [DATE'date2] ;;driveType: 0 fixed (hard drive)(default), 2 removable (eg flash), 3 same as 0, 4 network, 5 CD, 6 ramdisk;  flags: 0 file, 1 folder, 2 any, 4 not in folders, 8 only in folders, 16 date created

;Finds file and stores full path into sPath.
;Searches in specified drives or in drives of specified type.


;filename - filename, eg "qm.exe"
;sPath - will receive full path
;drives - string consisting of drive letters, eg "cef". Can be "".
;driveType - search in drives of this type. Used only if drives is "".
;date1, date2 - file modified time must be between date1 and date2.


;EXAMPLE
;str s
;if(FindFileInDrives("qm.exe" s)) ;;search for qm.exe in all hard drives

,;out s
;else

,;out "not found"


def DRIVE_UNKNOWN    0
def DRIVE_NO_ROOT_DIR 1
def DRIVE_REMOVABLE  2
def DRIVE_FIXED      3
def DRIVE_REMOTE     4
def DRIVE_CDROM      5
def DRIVE_RAMDISK    6
dll kernel32 #GetLogicalDrives
dll kernel32 #GetDriveType $nDrive

sPath.fix(0)
str s.from(" :\" filename) sd; int i dt dm; Dir d
int nd=len(drives)
if(nd)
,for i 0 nd
,,s[0]=drives[i]
,,foreach(d s FE_Dir 0x4^flags date1 date2) sPath=d.FileName(1); ret 1
else
,if(!driveType) driveType=DRIVE_FIXED
,sd=" :\"
,dm=GetLogicalDrives ;;32-bit mask of available drives
,for i 0 26
,,if(dm>>i&1=0) continue
,,sd[0]='A'+i
,,dt=GetDriveType(sd); if(dt>6) dt=0
,,if(dt!=driveType) continue
,,s[0]='A'+i
,,foreach(d s FE_Dir 0x4^flags date1 date2) sPath=d.FileName(1); ret 1
#8
thank you that works greatttttttt Big Grin
#9
Can this function be used to also find any file consisting of a specific word in all the drives? For example, I would like to find any file with the word "apple.txt", not case sensitive, in all the drives. Will this work? The old dos commands, one would use dir *apple*.txt. How would this be done on QM?
#10
Yes, * and ? can be used in file name.
#11
hi gin,

how can i use this when i want to make an exe-file ???

thx

maxxx


Forum Jump:


Users browsing this thread: 1 Guest(s)