Sign in to follow this  
Followers 0
nico666

FileGetdir ?

7 posts in this topic

Hello everybody, I'm searching for something for get the file dir... I found FilegetFullName but I don't want the name of the file with :whistle: only the dir.

How can I do that? ;)

Bye

Share this post


Link to post
Share on other sites



Hello everybody, I'm searching for something for get the file dir... I found FilegetFullName but I don't want the name of the file with :whistle: only the dir.

How can I do that? ;)

Bye

_PathSplit() ?


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

hmmm I have this script:

#Include<file.au3>
#include <array.au3>

$aArray = _ParseAndFind(@UserProfileDir&'\', 'test.txt')

Func _ParseAndFind($hDirectory, $hFindFile, $iDelete = 0, $iPrompt = 0, $iOverRide = 0) 
    RunWait(@Comspec & ' /c dir /b /s /a "' & $hDirectory & '" > "' & _
        @TempDir & '\RecursivOutput.txt"', @WorkingDir, @SW_HIDE)
    If Not FileExists(@TempDir & '\RecursivOutput.txt') Then Return SetError(1, 0, 0)
    Local $hFoundFiles = FileRead(@TempDir & '\RecursivOutput.txt')
    FileDelete(@TempDir & '\RecursivOutput.txt')
    If Not $hFoundFiles Then Return SetError(2, 0, 0)
    Local $sHold = '', $aSplit = StringSplit(StringStripCR($hFoundFiles), @LF)
    For $iCC = 1 To UBound($aSplit) - 1
        If StringTrimLeft($aSplit[$iCC], StringInStr($aSplit[$iCC], '\', 0, -1)) = $hFindFile Then
            If $iPrompt And $iDelete Then
                If MsgBox(36, 'Delete?', 'Would you like to delete:' & @CR & $aSplit[$iCC]) = 6 Then
                    If Not FileDelete($aSplit[$iCC]) And $iOverRide And StringInStr(FileGetAttrib($aSplit[$iCC]), 'R') Then
                        FileSetAttrib($aSplit[$iCC], '-R')
                        If FileDelete($aSplit[$iCC]) Then $sHold &= $aSplit[$iCC] & @LF
                    Else
                        $sHold &= $aSplit[$iCC] & @LF
                    EndIf
                EndIf
            ElseIf $iDelete Then
                If Not FileDelete($aSplit[$iCC]) And $iOverRide And StringInStr(FileGetAttrib($aSplit[$iCC]), 'R') Then
                    FileSetAttrib($aSplit[$iCC], '-R')
                    If FileDelete($aSplit[$iCC]) Then $sHold &= $aSplit[$iCC] & @LF
                Else
                    $sHold &= $aSplit[$iCC] & @LF
                EndIf
            Else
                $sHold &= $aSplit[$iCC] & @LF
            EndIf
        EndIf
    Next
    If $sHold Then Return StringSplit(StringTrimRight($sHold, 1), @LF)
    Return SetError(3, 0, 0)
EndFunc

So the File is $aaray[1] but How can I get the dir of this file? can you do it with the _pathsplit? I don't know ohw to use it :whistle:

Share this post


Link to post
Share on other sites

I remember writing that... Sure you can get the directory of it. Just use the $aArray[n] as the string in _PathSplit().


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

I found how to do :whistle:

Dim $szDrive, $szDir, $szFile, $stExt
$reetarray = _PathSplit($aArray[1],$szDrive,$szDir,$szFile,$stExt)
$path = $szDrive & $szDir

thanks

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Well, if you need only the path...

Func _FileGetDir($fPath)
       Return StringLeft($fPath, StringInStr($fPath, '\', 0, -1) - 1)
EndFunc

it should work

Edited by tittoproject

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0