Jump to content

Recommended Posts

  • 4 weeks later...
Posted (edited)

Hi guys! This is amazing function and it work fine with files. Problem is that I couldn't make it to work with folders...

#include <File.au3>
#include <Array.au3> ; i dont need this but i also did try with arrays
#include <_FileSearch.au3>
#include <string.au3>
 
 
; $file contain list of folders separated by @CR which I would like to find and copy to desired place
; filenames inside contain symbols like "-" "_" "(" ")" but that shouldnt be a problem
$file="search.txt"
; set counter on 1st line in search.txt
$cnt01=1
; $destination where i want all files to be copied to
$destination="f:\S\@@\"
; $countlines
$countlines=_FileCountLines("search.txt")
 
 
Do
; $fol is the name of first folder from the list (search.txt) that i want to find and copy to $destination
$fol=FileReadLine($file,$cnt01)
; $relpath should contain full path to first folder that has been found
; 15 is search depth, 1 means i want full path to a folder and 0 means it wont be an array
$folpath=_FolderSearch('f:\M\',$fol,15,1,0)
; copy folder and its contents to a $destination ,1 and overwrite files if there are any
DirCopy($folpath, $destination, 1)
; increase counter to read next line in search.txt
$cnt01 = $cnt01 + 1
; work like that until last line in file
Until $cnt01 > $countlines
; do a beep beep when everything is done
Beep(1000,100)
Exit

I did try and put MsgBox with variables to see what happens but couldnt make it to find first folder i would like to be found

It gets first folder name well but I couldnt get the hit from function:

$relpath=_FolderSearch('f:\M\',$fol,15,1,0)

Contents of a search.txt would be something like this:

Pictures_Not-Vacation_Sea-(2001)-Me

Video_And_Sounds-Vacation_Sea-(2001)-Me

etc.

Edited by Fr33b0w
Posted (edited)

Fr33b0w

; $Include = True (parameters can not be ignored)
; 1 - result in an ARRAY where $array[0]=number of folders (BY DEFAULT)
$folpath=_FolderSearch('f:\M\',$fol, True,15)
If Not @error Then
For $i = 1 to $folpath[0]
  DirCopy($folpath[$i], $destination, 1)
Next
EndIf

the script works well, tested

#include <File.au3>
#include <_FileSearch.au3>
$file="search.txt"
$cnt01=1
$destination="F:\S\@@\"
$countlines=_FileCountLines("search.txt")
While $cnt01 <= $countlines
$fol=FileReadLine($file,$cnt01)
; $Include = True (parameters can not be ignored)
; 1 - result in an ARRAY where $array[0]=number of folders (BY DEFAULT)
$folpath=_FolderSearch('F:\M\',$fol, True,15)
If Not @error Then
For $i = 1 to $folpath[0]
  DirCopy($folpath[$i], $destination&'\'&$fol, 1)
Next
EndIf
$cnt01 += 1
WEnd
Beep(1000,100)
Edited by AZJIO
Posted (edited)

1. Try _FileSearch_example

2. Try $fol = '*'

3. Check the error after the function _FolderSearch

$folpath=_FolderSearch('F:\M\',$fol, True,15)
MsgBox(0, 'Message', @error)

4. Check that the folder names are in the file search.txt

5. Check the simplified method

$folpath=_FolderSearch('F:\M\', 'Pictures_Not-Vacation_Sea-(2001)-Me', True,15)
MsgBox(0, 'Message', @error)
Edited by AZJIO
Posted

I am so sorry. I was lost my head while I had problem with script before You helped me first time and since I was trying everything to make it work I forgot to switch back hdd letter. So I wasted Your time even more then it was needed (mine time also). Script works in background and it works perfect. This what You made is very useful tool, at least it is for me so I thank You very much for that (spasibo)! Again, thank You for Your time. I wouldnt make it if You didnt helped me!

  • 1 month later...
Posted (edited)

I have been using _filesearch for a few months but I have recently ran into a problem. Currently I can only get it to work over the network if I map a drive to the other machine. Has anyone else been able to use the IP to do searches? I.E. 192.168.0.10folder Every time I try it returns no results. Another question I have is it states in the comments "If an empty folder, it returns an empty string or array with one element $array[0]=0". Now I have very limited experience with Autoit but I have taken classes in C and C++. Can you have an array with only one element in autoit? The reason why I ask is from my testing it seems that it is not returning an array when no files are found, just a variable with value "0" in it. Thank you for this function and any help you can offer.

Edited by pbc0011
Posted (edited)

Function is updated, and now if the folder is empty or nothing is found, it returns an @error=3

192.168.0.10folder

Remove the line in the function _FileSearch and _FolderSearch

If Not StringRegExp($Path, '(?i)^[a-z]:[^/:*?"<>|]*$') Or StringInStr($Path, '') Then Return SetError(1, 0, '')

I tried to use a regular expression to validate the path. But I do not understand what paths are used for network drives to make a regular expression. Maybe it does not even need to check.

Edited by AZJIO
Posted

Azjio,

Thanks for the quick response and making the adjustments. I'm having a little trouble understanding what exactly the @error macro does but Ill have to dig a little deeper into the help file. I really do need the ability to search over the network so I'm going to try and do a little research on that too.

  • 1 month later...
  • 2 weeks later...
Posted

_PathSearch

#include <Array.au3> ; для _ArrayDisplay
#include <_FileSearch.au3>
$FileList=_PathSearch('C:WINDOWSsystem', '*ystemm*|*ystem*z*|*ystemo*', True, 125)
; $FileList=_GetListMask('C:WINDOWSsystem', '*ystemM*', False, 125)
MsgBox(0, 'Сообщение', $FileList)
$FileList = StringSplit($FileList, @CRLF, 1)
_ArrayDisplay($FileList, UBound($FileList)&' - RegExp')
; Получение списка и обработка регулярным выражением
Func _PathSearch($Path, $Mask, $Include, $Depth)
Local $aFileList, $FileList
$FileList=_FileSearch($Path, '*', True, $Depth, 1, 0)
$Mask = StringReplace(StringReplace(StringRegExpReplace($Mask, '[][$^.{}()+]', '$0'), '?', '.'), '*', '.*?')
If $Include Then
  $aFileList = StringRegExp($FileList, '(?mi)^(' & $Mask & ')(?:r|z)', 3)
  $FileList = ''
  For $i = 0 To UBound($aFileList) - 1
   $FileList &= $aFileList[$i] & @CRLF
  Next
Else
  $FileList = StringRegExpReplace($FileList & @CRLF, '(?mi)^(' & $Mask & ')rn', '')
EndIf
$FileList = StringReplace(StringTrimRight($FileList, 2), '|', '')
Return $FileList
EndFunc
Posted

Thanks for the PathSearch option

Ive just been playing with it to try and understand it with this

$FileList=_PathSearch('C:Program Files (x86)', 'mbam.exe|mbamgui.exe', True, 125)
MsgBox(0, '?????????', $FileList)
$FileList = StringSplit($FileList, @CRLF, 1)
_ArrayDisplay($FileList, UBound($FileList)&' - RegExp')

But it doesn't return anything.. what have i missed?

Edit even running the one you posted unaltered returns nothing either

Posted (edited)

'mbam.exe|mbamgui.exe' - it's files, look for them using _FileSearch will be faster.

first try to play with _FileSearch_Gui_Test.au3

using _PathSearch need to change the mask of '*mbam.exe |*mbamgui.exe'

Edited by AZJIO
Posted (edited)

there we go

I knew it would be something stupid im doing lol

PathSearch will hopefully be usefull to me because i can search for more than one file to guarentee its installed but return the path if they exist, which i can feed to another function

Is wildcards in the path possible? ie: Program*

Im aware i can use @ProgramFilesDir, i was just curious?

благодарность

Jez

Edited by Chimaera
Posted

Chimaera

_FileSearch - searches for file names

_FileSearch(@WindowsDir, '*yste*')

C:WINDOWSsystem32configsystem.LOG

_PathSearch searches for text in a file path, and allow the ""

_PathSearch(@WindowsDir, '*yste*')

C:WINDOWSsystem32shell32.dll

  • 2 months later...
Posted
  • 3 months later...
Posted (edited)

for functions _FO_FileSearch, _FO_FolderSearch

$sLocale - Symbols of the local language (any non-Latin), to ignore the case when searching

$FileList=_FO_FileSearch($Path, '*Пример*', True, 125, 3, 1, 1, 'А-яЁё')

Update

;$sLocale - case sensitive.

; |0 - not case sensitive (only for 'A-z'), by default.

; |1 - case sensitive (for any characters)

; |<symbols> - not case sensitive, specified range of characters from local languages. For example 'А-яЁё'. 'A-z' is not required, they are enabled by default.

Edited by AZJIO

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...