Search the Community
Showing results for tags 'Wildcard'.
-
Hello, i want to search several directories for files with the largest numbers behind them (Like "video123") . They dont have a datatype. But there are also files with longer names and datatypes in these folders (Like "video778.mp4"). Is it possible to filter the _FileListToArray Syntax from to smth. like Here is my Code #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <array.au3> #include <File.au3> $filedir = @ScriptDir & "\" _checkfile() Func _checkfile() ConsoleWrite("______________________" & @CRLF) Local $arr[3] = ["music", "picture", "video"] For $i = 0 To UBound($arr) - 1 Local $arrayfiles = _FileListToArray($filedir & $arr[$i], $arr[$i] & "*", 1) If @error = 1 Then ConsoleWrite($arr[$i] & "Error 1") EndIf If @error = 4 Then ConsoleWrite($arr[$i] & "Error 2") ;Exit EndIf $arrayfilter = _ArrayMax($arrayfiles, 0, 1) Global $stringfiles = StringReplace($arrayfilter, $arr[$i], "") ConsoleWrite($arrayfilter & @CRLF) Next EndFunc ;==>_checkfile
- 9 replies
-
- _filelisttoarray
- wildcard
-
(and 2 more)
Tagged with:
-
Hi, I'm looking to create a script which will download all *.txt files from a remote FTP server. Once downloaded, delete all *.txt files. Can this be achieved using AutoIt ?
-
Hi, How to create Wildcards to search for a Filename and also for a String within a File and within the own script.
-
Strange behaviour with _FileListToArrayRec
jguinch posted a topic in AutoIt General Help and Support
In a folder with some files that have no extension (for example the hosts file in C:\Windows\System32\driversetc), FileListToArrayRec does not return the same thing than _FileListToArray if I use *.* as filter : _FileListToArray("C:\Windows\System32\driversetc", "*") : returns all files _FileListToArray("C:\Windows\System32\driversetc", "*.*") : returns all files _FileListToArrayRec("C:\Windows\System32\driversetc", "*") : returns all files _FileListToArrayRec("C:\Windows\System32\driversetc", "*.*") : returns only files with extensions It seems logic that FileListToArrayRec and FileListToArray should have the same behaviour with the same filter, no ? It's not important at all for me, but maybe developers will want to ensure that these two functions react in the same way... Edit : sorry if this post is not in the good section. Please move it if needed. -
WildcardMatch an Fast Filename Pattern Match (UDF) Machine Code Version (x32 and x64) Repeat the word from an C/C++ Writer { Introduction Simple wild card matching with ? and * is something that we use in our every day work just when opening a command prompt and using DIR and DEL. But how can this be done correctly in your program? OK, you can use regular expressions, and I recommend this when you already use a bunch of Boost, tr1 or STL stuff in your code. But sometimes, I like it easy and simple without tons of library code in the background. And because I saw a lot of wrong and in complex queries "wrong/failing" code, I just offer this small algorithm here. Background This wildcard matching function works just the same way as you expect and know it from the CMD.EXE DIR command. Using the Code The function just takes the string to check as a first argument and the mask with or without any wildcard characters as a second argument. It returns true if the strings match and false if not. It isn't spectacular. The characters ? and * are treated as wildcards. A ? character matches exactly one character and doesn't match an empty string. A * character matches any sequence of characters and an empty string too. Other characters are compared caseless. I use CharUpper and convert them to uppercase to perform this task. Feel free to use your own favorite way. Because * matches any character sequence and an empty string WildcardMatch(_T(""),_T("*")) returns true. } by Martin Richter, 28 Apr 2011 on codeproject.com AutoIt3 WildcardMatch No, I'm not doing any translation the C/C++ WildcardMatch to our favorite scripting language: AutoIt V3. Instead modificate thats source to be: - Ansi and Wide text version of WildcardMatch. - Portable and meet the condition to be used on Shell Code or Machine Code (That what Ward, trancexx and other called it!). And then write an UDF. UDF Name : CoreFx.Wildcard.au3 Functions : CoreFx_WildcardMatchExA($string, $patern) CoreFx_WildcardMatchExW($string, $patern) Includes : CoreFx.DynamicCode.au3 General.Imports.au3 WinAPI.Kernel32.au3 Platform : x32 and x64 bit Sample : $test.au3 . Download In Single ZIP (File Size: 5 KB. All required file are included). CoreFx.Wildcard.zip Sample $test.au3 Outputs: Ansi Test Empty string 1 CoreFx_WildcardMatchExA("", "*") Return 1 Empty string 2 CoreFx_WildcardMatchExA("", "") Return 1 Simple 1 CoreFx_WildcardMatchExA("MyName.doc", "*.DOC") Return 1 Simple 2 CoreFx_WildcardMatchExA("MyName.docx", "*.DOC") Return 0 Complex 1 CoreFx_WildcardMatchExA("MyNamName.docx", "My*Name.*x") Return 1 Complex 2 CoreFx_WildcardMatchExA("MyNamName.docx", "My*Name.*oc") Return 0 A CoreFx_WildcardMatchExA("filename.txt", "*.txt") Return 1 B CoreFx_WildcardMatchExA("filename.txt", "*.tx?") Return 1 C CoreFx_WildcardMatchExA("filename.txt", "file*name.txt") Return 1 D CoreFx_WildcardMatchExA("filename.txt", "fil*ame.txt") Return 1 E CoreFx_WildcardMatchExA("filename.txt", "f*l*a*e.*x?") Return 1 Wide Test Empty string 1 CoreFx_WildcardMatchExW("", "*") Return 1 Empty string 2 CoreFx_WildcardMatchExW("", "") Return 1 Simple 1 CoreFx_WildcardMatchExW("MyName.doc", "*.DOC") Return 1 Simple 2 CoreFx_WildcardMatchExW("MyName.docx", "*.DOC") Return 0 Complex 1 CoreFx_WildcardMatchExW("MyNamName.docx", "My*Name.*x") Return 1 Complex 2 CoreFx_WildcardMatchExW("MyNamName.docx", "My*Name.*oc") Return 0 A CoreFx_WildcardMatchExW("filename.txt", "*.txt") Return 1 B CoreFx_WildcardMatchExW("filename.txt", "*.tx?") Return 1 C CoreFx_WildcardMatchExW("filename.txt", "file*name.txt") Return 1 D CoreFx_WildcardMatchExW("filename.txt", "fil*ame.txt") Return 1 E CoreFx_WildcardMatchExW("filename.txt", "f*l*a*e.*x?") Return 1 . Source A Simple Wildcard Matching Function (Martin Richter [MVP C++]) Wikipedia Wildcard Character . For modified version of WildcardMatch (C++ source). If you need it, just pm me!
-
- Wildcard
- file pattern
- (and 5 more)
-
How to put wildcard characters in a string?
Kidney posted a topic in AutoIt General Help and Support
So im making a script that organizes TV shows. i have figured most of it out but im trying to find the portion of the title that contains the Season number and Episode number. (ie S01E13) is there and easy way to search for the "S" and "E" in a string with any 2 random numbers in between them and after the "E"? here is what i tried just as a very wild guess: Func FindSeasonEpisode($FileName) $result = StringInStr($FileName, "S**E**") ConsoleWrite($result & @CRLF) EndFunc -
Finding File name from wildcard search?
Normonator posted a topic in AutoIt General Help and Support
Here is a small section of my script. What I am trying to accomplish is that I am finding these files by using wildcards in fileexists(). Is there any possible way to get the filename based off of wildcards if only one file matches the criteria? Something like filegetname("1*.bkf") that returns the full file name. I would like this script to be able to stringtrimleft($string,1) the filename, so that I can change the first portion of file name. File name example: "0 01-31-13 16.01.20 full System Backup.bkf" would change to: "1 01-31-13 16.01.20 full System Backup.bkf" For $z = 5 to "0" Step -1 If FileExists($backupdest & $z & "*.bkf") Then FileMove($backupdest & $z & "*.bkf",$backupdest & ($z+1) & "*.bkf",0) EndIf Any help would be appreciated. Thanks. -
Hi guys, i need you help, again I have a folder that changes everytime the name. Basically is: test-test-123456789 The name test-test is equal everytime, the number 123456789 changes. The problem is this: i have to use cmd for build a file in this directory. It's a simple script to avoid the MAX_LENGHT of cmd ( max 256 character limit ) The directory is: @workingdir & "\test-test-123456789\build\test.sln This is the script: $var1 = "cd Windows\Microsoft.NET\Framework\v4.0.30319" $var2 = $var3 = @WorkingDir & $var2 & "\build\test.sln" Run(@ComSpec) Send(".cd C:\") Send("{ENTER}") Send($var1) Send("{ENTER}") Send($var3) I don't know how to set $var2, because the name changes everytime. I have also the same problem with directory of Framework ( v4.0.30319 ), but if i know how to set the variable for test-test i can apply for .NET directory Thanks for support