Search the Community
Showing results for tags 'filename'.
-
AppendVersion_X64 AppendVersion_x64 is a simple program intended to expedite the systematic renaming of executable installation files, compressed installation files and Start Menu links that point to installed executable program files. In this discussion, 'target executable file' can refer to an uncompressed installation executable, or to the compressed installation executable file inside a packaged compressed file (zip, 7z, rar or tar), or to the executable file that a Start Menu link points to. A 'rename target' can refer, again, to an uncompressed installation executable file, or to the compressed file containing a packaged target executable file, or to a Start Menu link pointing to a target executable file. There are four scenarios for AppendVersion processing: An installation executable file is renamed and appended with that target executable file's own file version number. A compressed installation file (zip, 7z, tar, or rar) is renamed and appended with its compressed target executable file's own file version number. A Start Menu link pointing to its target executable file is renamed and appended with that target executable file's own version number. A folder is selected containing any assorted collection of rename target types. Having an archived program installation file renamed with its target executable file's file properties version number appended to the installation file's name, in a systematic format, aids in quickly determining whether or not you have the latest version installed. Having all the Start Menu program links (rename targets) appended with their target executable file's version numbers quickly aids in determining whether or not you have the most recent published upgrade or update of that program installed. Hovering your mouse over a Start Menu link will conveniently display the target executable file's version number. Start Menu links exist in two system folders: @ProgramsDir (%appdata%\Microsoft\Windows\Start Menu\Programs) @ProgramsCommonDir (%programdata%%\Microsoft\Windows\Start Menu\Programs) Renaming Start Menu links in these two folders require Administrator privilege. You can either compile this AppendVersion.au3 script with the #RequireAdmin macro at the top of the script, or go to the compiled executable 'AppendVersion_x64.exe' file's Properties Compatibility tab and check 'Run this program as an administrator'. ==== AppendVersion can also receive full file path argument parameters via Run or the Windows terminal. This allows for processing files from different directory locations in one AppendVersion session. ==== AppendVersion is initiated via a Windows SendTo 'AppendVersion' link. Running the compiled executable 'AppendVersion_X64.exe' once will auto-create an 'AppendVersion' link in the SendTo subfolder if the SendTo link does not exist and will also create a default Settings.ini file in the @ScriptDir folder if the Settings.ini file does not exist. The Settings.ini file maintains basenames and other configuration data that AppendVersion requires. ==== Icon @ScripDir subfolder location directive for compiling AppendVersion_x64.au3 is: #AutoIt3Wrapper_Icon=.\Icon\add2.ico ==== To use AppendVersion, in Windows Explorer select one or more rename target files, rename target links and any folders containing rename target files or links, then select the SendTo 'AppendVersion' link. You can also right-click on a Start Menu link and select Open Location: After Windows Explorer opens, right-click on the highlighted rename target link and then select 'AppendVersion' from the SendTo menu. You can also process Start menu rename target links enmasse in succession by selecting one of the two Programs folders where Windows maintains most all the Start Menu links: %appdata%\Microsoft\Windows\Start Menu %programdata%\Microsoft\Windows\Start Menu Select one of the two Programs folders and then select 'AppendVersion' from the SendTo menu You can process both Programs folders in one session by running the compiled executable 'AppendVersion Start Menu Links_x64.exe'. ==== The script maintains processed file identification data in the Settings.ini [BaseNames] section. This section is used in identifying new updated versions of earlier files previously processed by AppendVersion. This file identification data (key basenames and fingerprint value) is used to compare and systematically rename later matching updated versions of the identified file. 'Basename(s)' is one or two substrings in the installation file that usually does not change in the rename target file name from one file version to the next. Except for file size and file/product version properties, which can change with every new file version, the remaining available target file properties are concatenated together to create a target file properties 'fingerprint'. The fingerprint consists of file properties that usually will not change from one target file version to the next, i.e., 'File Description', 'Product Name', 'Copyright', 'Language', 'Original File name', 'Legal Trademarks', 'Company Name' and 'DefaultLangCodePage'. The basename(s) and fingerprint together constitute the 'identification' of a candidate file. This ID is used to identify later downloaded versions of the file that can be automatically renamed without user interaction. If the target executable file's properties does not have a file version number, the file's product version number will be used instead in the version appending and renaming of the file. If the target executable has neither a file version nor product version number, the user will be prompted to enter the published file version number acquired from the provider's web site. Both the basename(s) and version numbers will be used for the renaming of the file. If the rename target file is in a popular compressed format, i.e., (*.zip, *.7z, *.rar, and *.tar), the script will use PeaZip-portable to decompress the zipped file into a temporary folder (@ScripDir & "\UnZip") and then prompt the user to select the target executable file with file properties used in the rename target 'identification'. The freeware PeaZip portable can be downloaded from: https://peazip.github.io/peazip-portable.html Unpack PeaZip portable into the @ScripDir & "\peazip" subfolder. Once the target executable file properties are read from the target executable, the user will be prompted to configure the basename(s) from the rename target file name, unless an identification already exists in Settings.ini, in which case the rename target file will automatically be renamed by AppendVersion. The process is not always fully automatic. If the target executable file has neither a file nor product version in its file properties, the user will be prompted to manually enter the published file version number. Process example, the target file for renaming is: FreeFileSync_11.14_[Donation_Edition]_Windows_Portable.zip Righ-click on the file. Select 'AppedVersion' from the SendTo submenu. The script, recognizing the rename target file as a compressed file (*.zip, *.7z, *.tar, and *.rar), will decompress the rename target file into a temporarily created @ScriptDir & '\UnZip' folder. Then, the user will then be prompted to select from the folder or subfolder containing the target executable file from which the file properties will be read: 'FreeFileSync_11.14_[Donation_Edition]_Setup.exe'. Once the target executable file is selected and opened, the script will prompt the user to create one or two basename(s) from the rename target zip file's name. Base name(s) are created from the rename target zip file name (without extension): Examples, 'FreeFileSync_' , '[Donation_Edition]' and '_Windows_Portable'. Base names must be separate substrings in the rename target zip file's name. The user can choose to use just one or two base names for file identification. The user can also choose to use the entirety of the original rename target zip file name: 'FreeFileSync_11.14_[Donation_Edition]_Windows_Portable' as a base name in renaming later versions of FreeFileSync. This may not be advisable with this base name, since later versions of this rename target file name will not have version '11.14' in the name, but this naming convention is an option. In this example, I will use the 'FreeFileSync_" and '[Donation_Edition]' substrings as base names, since these are file name structures that are unique to the file name and will probably not change in later published file version names. The file properties fingerprint collected from the FreeFileSync.exe executable is: FreeFileSyncFreeFileSync.orgFreeFileSync-FolderComparisonandSynchronization040904B0 To use two base names for later automatic file version identification, the base names must be separated with a colon ':', i.e., 'FreeFileSync_:[Donation_Edition]'. If a later file version of a candidate rename target file's name contains both of these substrings and has the same target executable file properties 'fingerprint', the script will automatically identify and rename the later-versioned file's name. The combined file identification of [Key] base names + [Value] fingerprint is: FreeFileSync_:[Donation_Edition]=FreeFileSyncFreeFileSync.orgFreeFileSyncFolderComparisonandSynchronization040904B0 This identification is stored in the Settings.ini file under the [BaseNames] section. When a new version of FreeFileSync_XX.XX_[Donation_Edition]_Windows_Portable.zip is processed by AppendVersion, if an entry in Settings.ini [BaseNames] section can match the rename target's file name and also match the candidate target executable's fingerprint, the script will use this to automatically rename the zip file. Finally, the rename target file is then renamed with the base name(s) and with one of three version prefixes to the version number: " - fver_ "; for files with a properties file version number (preferred default) " - pver_ "; for files without file version numbers but with product version numbers(fallback) " - uver_ "; for files with neither file nor product numbers. User manually entered published file version number. NOTE: These version format prefixes can be changed in Settings.ini [QuotedPrefix] section to meet your prefix format preferences. The [QuotedPrefix] section value entries must be quoted. In this example, FreeFileSync.exe contains a properties file version number of 11.14.0.0 The resultant AppendVersion renamed file is: FreeFileSync_[Donation_Edition] - fver_ 11.14.0.0.zip This systematic approach works well with most file names, but files with short file names such as 'a.exe' and having no finger-printable file properties are problematic. In such case, perhaps renaming the downloaded file with a longer, unique name before running this script on it is preferrable, although renaming the file before processing it with AppendVersion circumvents the purpose of the script. This would not be an issue if software creators would always include full file properties in their file compilations. Settings.ini add2.ico ReadMe.pdf AppendVersion Start Menu Links.au3 AppendVersion.au3
-
- filename
- file properties
-
(and 2 more)
Tagged with:
-
Hi guys! i want to write speedy and very fast code to check if chosen filename exists then add "-1" at end of it and if chosen filename exists again, add "-2" instead of "-1" and check filename until be unique. For Example: I have to write "Filename.txt" in C:\ directory with FileOpen then check if "Filename.txt" exists in that directory then rename chosen filename to "Filename-2.txt" and if exists again in directory, rename chosen filename to "Filename-3.txt" and do this work until to find unique number to add end of filename. ====================== SOLUTION by @Subz ======================
-
I have a problem with FileOpenDialog using long default filenames ... they always get truncated. For example: "A Long FileName.mpg" as a default would prompt as just "FileName.mpg" (but scrolling left will show it named correctly). Does anyone know of a fix for this please (I didn't spot it in a Forum search), or is it one for the bug tracker? #include <FileConstants.au3> #include <MsgBoxConstants.au3> Local Const $sMessage = "Hold down Ctrl or Shift to choose multiple files." Local $sFileOpenDialog = FileOpenDialog($sMessage, @WindowsDir & "\", "Images (*.jpg;*.bmp)|Videos (*.avi;*.mpg)", BitOR($FD_FILEMUSTEXIST, $FD_MULTISELECT), "A Long FileName.mpg") Thanks,
- 3 replies
-
- fileopendialog
- default
-
(and 1 more)
Tagged with:
-
Hi All, I have many files inside folder with ID Number. The problem here is I want to get ID Number, file name inside folder and Get Size of its. However when I use loop "For" the result appeared with duplicate data. Please check the example in attached file and help me make the code below better for this case. #include <File.au3> #include <Array.au3> Global $a, $b $a = _FileListToArrayEx(@ScriptDir, '*.visf') For $i = 1 to $a[0] $b = StringSplit($a[$i], "\") ;~ _ArrayDisplay($b) For $j = 1 to $b[0] ;~ ConsoleWrite($b[$b[0] - 1] & '_' & $b[$b[0]] & ' ' & FileGetSize($a[$i]) & @CRLF) FileWrite(@ScriptDir & '\result.txt', $b[$b[0] - 1] & '_' & $b[$b[0]] & ' ' & FileGetSize($a[$i]) & @CRLF) Next Next Func _FileListToArrayEx($s_path, $s_mask = "*.*", $i_flag = 0, $s_exclude = -1, $f_recurse = True, $f_full_path = True) If FileExists($s_path) = 0 Then Return SetError(1, 1, 0) ; Strip trailing backslash, and add one after to make sure there's only one $s_path = StringRegExpReplace($s_path, "[\\/]+\z", "") & "\" ; Set all defaults If $s_mask = -1 Or $s_mask = Default Then $s_mask = "*.*" If $i_flag = -1 Or $i_flag = Default Then $i_flag = 0 If $s_exclude = -1 Or $s_exclude = Default Then $s_exclude = "" ; Look for bad chars If StringRegExp($s_mask, "[/:><\|]") Or StringRegExp($s_exclude, "[/:><\|]") Then Return SetError(2, 2, 0) EndIf ; Strip leading spaces between semi colon delimiter $s_mask = StringRegExpReplace($s_mask, "\s*;\s*", ";") If $s_exclude Then $s_exclude = StringRegExpReplace($s_exclude, "\s*;\s*", ";") ; Confirm mask has something in it If StringStripWS($s_mask, 8) = "" Then Return SetError(2, 2, 0) If $i_flag < 0 Or $i_flag > 2 Then Return SetError(3, 3, 0) ; Validate and create path + mask params Local $a_split = StringSplit($s_mask, ";"), $s_hold_split = "" For $i = 1 To $a_split[0] If StringStripWS($a_split[$i], 8) = "" Then ContinueLoop If StringRegExp($a_split[$i], "^\..*?\..*?\z") Then $a_split[$i] &= "*" & $a_split[$i] EndIf $s_hold_split &= '"' & $s_path & $a_split[$i] & '" ' Next $s_hold_split = StringTrimRight($s_hold_split, 1) If $s_hold_split = "" Then $s_hold_split = '"' & $s_path & '*.*"' Local $i_pid, $s_stdout, $s_hold_out, $s_dir_file_only = "", $s_recurse = "/s " If $i_flag = 1 Then $s_dir_file_only = ":-d" If $i_flag = 2 Then $s_dir_file_only = ":D" If Not $f_recurse Then $s_recurse = "" $i_pid = Run(@ComSpec & " /c dir /b " & $s_recurse & "/a" & $s_dir_file_only & " " & $s_hold_split, "", @SW_HIDE, 4 + 2) While 1 $s_stdout = StdoutRead($i_pid) If @error Then ExitLoop $s_hold_out &= $s_stdout WEnd $s_hold_out = StringRegExpReplace($s_hold_out, "\v+\z", "") If Not $s_hold_out Then Return SetError(4, 4, 0) ; Parse data and find matches based on flags Local $a_fsplit = StringSplit(StringStripCR($s_hold_out), @LF), $s_hold_ret $s_hold_out = "" If $s_exclude Then $s_exclude = StringReplace(StringReplace($s_exclude, "*", ".*?"), ";", "|") For $i = 1 To $a_fsplit[0] If $s_exclude And StringRegExp(StringRegExpReplace( _ $a_fsplit[$i], "(.*?[\\/]+)*(.*?\z)", "\2"), "(?i)\Q" & $s_exclude & "\E") Then ContinueLoop If StringRegExp($a_fsplit[$i], "^\w:[\\/]+") = 0 Then $a_fsplit[$i] = $s_path & $a_fsplit[$i] If $f_full_path Then $s_hold_ret &= $a_fsplit[$i] & Chr(1) Else $s_hold_ret &= StringRegExpReplace($a_fsplit[$i], "((?:.*?[\\/]+)*)(.*?\z)", "$2") & Chr(1) EndIf Next $s_hold_ret = StringTrimRight($s_hold_ret, 1) If $s_hold_ret = "" Then Return SetError(5, 5, 0) Return StringSplit($s_hold_ret, Chr(1)) EndFunc Example.zip
-
I have an ini file which has structure as below. And I want to use this value and change only the file name in below path of another ini file. Can you suggest any approach.
-
Hi everyone Hope you're doing great today. Well, I have a little question about extracting a certain string from a file name to make comparison after treatment. Let's get into the details: First of all, I gather and store a machine BIOS Version by running this: RunWait(@ComSpec & " /c " & "wmic bios get SMBIOSBIOSVERSION >> C:\Drivers\Tag.txt" & @CRLF, "", @SW_HIDE, "$STDOUT_CHILD") _FileWriteToLine("c:\Drivers\BIOS_Version.txt", 1, "", 1) $sContent = FileRead ("C:\Drivers\BIOS_Version.txt") $sContent = StringRegExpReplace($sContent, " ", "") Result is, for example, A10 Then, I download the latest available BIOS version from the Dell related model website and the filename of the latest BIOS is stored in a $sBIOSName variable. Result is for example, E5440A14.exe What i can't figure out is how to extract the Bios name stored in the $sBIOSName knowing that each model this app would run won't have the same number of chars. Indeed, I have some OPL790AXX.exe / OPL7010AXX.exe / E5470AXX.exe etc... I imagine something like getting the whole string, left trimming it to the first A found count 2 chars on the right and store them to have the possibility to make the check between A10 and A14 (as the number of char of filenames is never the same) Hope this is clear If not, don't hesitate to ask for more. Thanks in advance for the help
-
Basically I'm looking to make a snapshot of a whole HD's folders and files in one text file. Just the names. Preferably in alphabetical order. Folder 1 File 1 File 2 File 3 Folder 2 Etc Is there a function that can copy just the names without opening the files? An alternative would be to put each into rename mode and then copy the text, but that is going to be painfully slow. Thanks.
- 3 replies
-
- filename
- foldername
-
(and 3 more)
Tagged with:
-
Hi Everyone! Been away from scripting for a bit and am a bit rusty. I was trying to get downloaded image filenames to increment by one. I was hoping to be able to check the last filename and continue from there if the program was closed and reopened again. #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form= $biolister = GUICreate("Form1", 125, 97, 192, 124) GUISetBkColor(0x99B4D1) $start = GUICtrlCreateButton("Start", 8, 40, 41, 33) GUICtrlSetBkColor(-1, 0x00FFFF) $stop = GUICtrlCreateButton("Stop", 72, 40, 41, 33) GUICtrlSetBkColor(-1, 0xFF0000) $Bio = GUICtrlCreateLabel("Bio Lister", 24, 8, 80, 28) GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $filename = 0 $sImgDir = "C:\filepathname\"&$filename&".jpg" $sImgUrl = "http://lorempixel.com/400/200" $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $stop Exit case $start InetGet($sImgUrl, $simgdir, 1, 0) if fileexists( $simgdir & $filename) then $filename + 1 EndSwitch WEnd
-
Hey guys! I tried looking for something like this in the web but could only find broken/impractical scripts or bogus download pages, so I made it and decided to share for future generations. The way it works is it takes all the files in the folder you run the script on, and given a choice it either turns the filename into "randomxx - filename.ext", "randomxx.ext" or you could use it to remove the "randomxx - " tag to undo what you did. Well at least I hope that's the way it works, so be careful and use at your own discretion! #include <File.au3> #include <Array.au3> $farray=_FileListToArray(@ScriptDir) Global $temp[UBound($farray)],$error=1,$count=0,$random[UBound($farray)+1],$ok=0 Do $flag=InputBox("Filename Randomizer","Hello, this script works in the folder you run it on, so be careful!"&@CRLF&@CRLF&"1 to randomize keeping name"&@CRLF&"2 to randomize ditching name"&@CRLF&"3 to remove randomized tag") If @error=1 Then Exit Switch $flag Case $flag = 1 $ok =1 Case $flag = 2 $ok =1 Case $flag = 3 $ok =1 Case Else $exit=MsgBox(5,"error","You must input a valid option") If $exit = 2 Then Exit EndSwitch Until $ok =1 If $flag=1 Or $flag=2 Then ProgressOn("Filename Randomizer","Organizing files...","0%") For $i=1 To UBound($farray)-1 ProgressSet(($i*100)/(UBound($farray)-1),Int(($i*100)/(UBound($farray)-1))&"%") If $farray[$i]=@ScriptName Then Sleep(1) Else $temp[$i]=$farray[$i] Local $crumps[UBound($farray)+1] If $farray[$i]=$i Then $error=1 Else $error=FileMove(@ScriptDir&""&$farray[$i],@ScriptDir&""&$i) EndIf $j=1 $k=$i If $error=0 Then Do $error=0 While $error=0 $crumps[$j]=$k For $index=1 to UBound($farray)-1 If $farray[$index] = $k Then ExitLoop Else If $k = UBound($farray)-1 Then MsgBox(0,"FATAL ERROR","One of the files is in use or something weird happened, sorry but I'm too lazy to work around this one, be more careful next time!") Exit EndIf EndIf Next $k=$index $error=FileMove(@ScriptDir&""&$farray[$k],@ScriptDir&""&$k) If $error=0 Then $j+=1 Else $farray[$k]=$k $j-=1 $k=$crumps[$j] If $j=0 Then FileMove(@ScriptDir&""&$farray[$i],@ScriptDir&""&$i) $farray[$i]=$i ExitLoop EndIf EndIf WEnd Until $j=0 Else $farray[$i]=$i EndIf EndIf Next EndIf $random=_RandomUnique($farray[0],0,$farray[0]-1,1) If $flag=3 Then ProgressOn("Filename Randomizer","Checking and renaming...","0%") For $i=1 To UBound($farray)-1 If $farray[$i]=@ScriptName Then Sleep(1) Else If $flag = 1 Then ProgressSet(($i*100)/(UBound($farray)-1),Int(($i*100)/(UBound($farray)-1))&"%","Renaming") FileMove(@ScriptDir&""&$farray[$i],@ScriptDir&""&"random"&$random[$i]&" - "&$temp[$i]) ElseIf $flag = 2 Then ProgressSet(($i*100)/(UBound($farray)-1),Int(($i*100)/(UBound($farray)-1))&"%","Renaming") $artempex=StringSplit($temp[$i],".") If @error=1 Then FileMove(@ScriptDir&""&$farray[$i],@ScriptDir&""&"random"&$random[$i]) Else $tempext=$artempex[UBound($artempex)-1] FileMove(@ScriptDir&""&$farray[$i],@ScriptDir&""&"random"&$random[$i]&"."&$tempext) EndIf ElseIf $flag = 3 Then ProgressSet(($i*100)/(UBound($farray)-1),Int(($i*100)/(UBound($farray)-1))&"%") $artempex=StringSplit($farray[$i]," - ",1) If Not @error=1 Then $rerror=StringInStr($artempex[1],"random",1) If Not $rerror=0 Then FileMove(@ScriptDir&""&$farray[$i],@ScriptDir&""&StringTrimLeft($farray[$i],3+StringLen($artempex[1]))) $count+=1 EndIf EndIf EndIf Next ProgressOff() If $count=0 And $flag=3 Then MsgBox (0,"","No files had that") Else MsgBox (0,"","Done! Press F5 on your folder") EndIf ; #FUNCTION# ==================================================================================================================== ; Version........: 1.1 - 2011/11/24 ; Name...........: _RandomUnique ; Description ...: Returns an array of unique random numbers ; Syntax.........: _RandomUnique($iCount, $nMin, $nMax, [$iInt = 0, [$nSeed = Default]]) ; Parameters ....: $iCount - The amount of numbers to generate Number between 1 and 10^6-1 ; $nMin - The smallest number to be generated. Number between -2^31 and 2^31-1 ; $nMax - The largest number to be generated. Number between -2^31 and 2^31-1 ; $iInt - [optional] If this is set to 1 then an integer result will be returned. Default is a floating point number. ; $nSeed - [optional] Seed value for random number generation. Number between -2^31 and 2^31-1 ; Return values .: Success - Returns a 1-dimensional array containing only unique numbers ; $Array[0] = count of generated numbers ; $Array[1] = first number ; $Array[2] = second number, etc ; Failure - Returns 0 and sets @error: ; | 1 - $iCount is too small ; | 2 - $iCount is too large ; | 3 - $nMin and $nMax are equal ; | 4 - $nMin is larger than $nMax ; | 5 - $nMin or $nMax exceeds limit ; | 6 - $nSeed exceeds limit ; Author ........: money ; Modified.......: ; Remarks .......: If $iInt is 1 and $iCount exceeds total unique numbers than @extend is set to 1 and item count is adjusted to the ; + maximum numbers that can be returned ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func _RandomUnique($iCount, $nMin, $nMax, $iInt = 0, $nSeed = Default) ; error checking Select ; $iCount is too small Case ($iCount < 1) Return SetError(1, 0, 0) ; $iCount is too large Case ($iCount > 10^6-1) Return SetError(2, 0, 0) ; $nMin and $nMax cannot be equal Case ($nMin = $nMax) Return SetError(3, 0, 0) ; $nMin cannot be larger than $nMax Case ($nMin > $nMax) Return SetError(4, 0, 0) ; $nMin or $nMax exceeds limit Case ( ($nMin < -2^31) Or ($nMax > 2^31-1) ) Return SetError(5, 0, 0) EndSelect ; user specific seed If IsNumber($nSeed) Then ; $nSeed exceeds limit If (($nSeed < -2^31) Or ($nSeed > 2^31-1) ) Then Return SetError(6, 0, 0) SRandom($nSeed) EndIf ; $iCount is equal too or exceeds maximum possible unique values Local $iCountInval = 0 If ($iInt) Then ; positive If ($nMin >= 0) Then If ($iCount > ($nMax-$nMin)+1) Then $iCountInval = 1 ElseIf ($iCount = ($nMax-$nMin)+1) Then $iCountInval = 3 EndIf ; negative to positive Else If ($iCount > ($nMax + Abs($nMin)+1)) Then $iCountInval = 2 ElseIf ($iCount = ($nMax + Abs($nMin)+1)) Then $iCountInval = 3 EndIf EndIf EndIf ; courtesy If ($iInt And $iCount = 1) Then Local $aArray[2] = [1, Random($nMin, $nMax, $iInt)] ; $iCount is too large so we will generate as much we can from $nMin to $nMax values ElseIf $iCountInval Then If $iCountInval = 1 Then $iCount = Int($nMax - $nMin)+1 ElseIf $iCountInval = 2 Then $iCount = Int($nMax + Abs($nMin))+1 EndIf ; $iCount is equal to total unique numbers If $iCountInval = 3 Then $iCountInval = 0 Local $aTmp, $iA, $iNumber = $nMin, $aArray[$iCount + 1] = [$iCount] ; add our numbers sequentially (from $iMin to $iMax) For $i = 1 To $aArray[0] $aArray[$i] = $iNumber $iNumber += 1 Next ; swap every x index value with a random index value For $i = 1 To $aArray[0] $iA = Random($i, $aArray[0], 1) If $i = $iA Then ContinueLoop If $iA = 0 Then $iA = $aArray[0] $aTmp = $aArray[$i] $aArray[$i] = $aArray[$iA] $aArray[$iA] = $aTmp Next Else ; everything else is ok, generate unique numbers Local $nRnd, $iStep = 0, $aArray[$iCount + 1] = [$iCount] While ($iStep <= $iCount-1) $nRnd = Random($nMin, $nMax, $iInt) ; check if the number already exist If IsDeclared($nRnd) <> -1 Then $iStep += 1 $aArray[$iStep] = $nRnd ; store our numbers in a local variable Assign($nRnd, '', 1) EndIf WEnd EndIf Return SetError(0, Number($iCountInval > 0), $aArray) EndFunc Thanks to money for such an efficient snippet!
- 4 replies
-
- filename
- randomizer
-
(and 3 more)
Tagged with:
-
Hi guys, i have a doubt using InetGet I have made this script: SplashTextOn("", "Downloading...", 200, 40, -1, -1, 1, "",10,"") Local $hDownload = InetGet("https://github.com/test/test/zipball/master", @WorkingDir & "\Test.zip", 1, 1) Do Sleep(250) Until InetGetInfo($hDownload, 2) InetClose($hDownload) SplashOff() MsgBox(0, "", "Completed") The script work, but i have made the filename ( Test.zip ) So i have this question: 1) Can automatically script set the original filename? 2) Can automatically script set the extension? (optional, i think is not possible) Thanks