Sample:
folder folder 2 asssszz.gif <===== asssszz2.gif asssszz3.gif folder 3 asssssaszz.gif <===== asssxsxszz2.gif asssxaxszz3.gif folder 4 asssssadasdszz.gif <===== asssxsxszz2.gif asssxaxszz3.gif
this files can be renamed to 1.gif
Posted 25 July 2012 - 11:27 AM
folder folder 2 asssszz.gif <===== asssszz2.gif asssszz3.gif folder 3 asssssaszz.gif <===== asssxsxszz2.gif asssxaxszz3.gif folder 4 asssssadasdszz.gif <===== asssxsxszz2.gif asssxaxszz3.gif
Posted 25 July 2012 - 11:44 AM
$split = StringSplit($array[$x], '.')
StringRight($split[1],1)
If StringIsDigit(StringRight($split[1],1)) Then
Posted 26 July 2012 - 05:31 AM
Posted 26 July 2012 - 12:42 PM
Edited by JLogan3o13, 26 July 2012 - 12:42 PM.
Posted 28 July 2012 - 05:47 AM
#include <Array.au3> Global $locations = "C:Documents and SettingsAll UsersDocumentsMy PicturesSample Pictures" Local $i, $get = False Global $Found_Files[1]; Try not to use Dim! $Total_files = DirGetSize($locations, 3) $Fh = FileFindFirstFile($locations & "*.*") While 1 $found = FileFindNextFile($Fh) If @error Then ExitLoop ConsoleWrite($found & @CRLF) If $Found_Files[0] = "" Then _ArrayPush($Found_Files, $found, 1) Else _ArrayAdd($Found_Files, $found) EndIf WEnd FileClose($Fh) ; You should close the Search file handle! _ArrayDisplay($Found_Files, "Search Result") For $i = 0 To UBound($Found_Files) - 1 FileMove($locations & $Found_Files[$i], $locations & StringReplace($Found_Files[$i], "_", ""), 0) Next
Edited by AHRIMANSEFID, 28 July 2012 - 07:56 AM.
Posted 28 July 2012 - 08:48 AM
#include <Array.au3> $files = _FileGetFirstFiles(@DesktopDir&'script',"*.txt") _ArrayDisplay($files,'before') For $x = 1 To $files[0] $split = StringSplit($files[$x], '.') If Not StringIsDigit(StringRight($split[$split[0]-1],1)) Then $split[$split[0]] = '0.'&$split[$split[0]] $files[$x] = _ArrayToString($split) EndIf Next _ArrayDisplay($files,'after') Func _FileGetFirstFiles($sDir,$searchString) Local $return[1],$search,$file Local $arr = _GetFilesFolder_Rekursiv($sDir,'*',1) ;~ _ArrayDisplay($arr,'tree_array') For $x = 1 To $arr[0] $search = FileFindFirstFile($arr[$x]&$searchString) If @error Then FileClose($search) Else While 1 $file = FileFindNextFile($search) If @error Then ExitLoop _ArrayAdd($return,$arr[$x]&$file) ExitLoop WEnd FileClose($search) EndIf Next $return[0] = UBound($return)-1 If $return[0] Then Return $return Else SetError(1) EndIf EndFunc ;================================================================================================== ; Function Name: _GetFilesFolder_Rekursiv($sPath [, $sExt='*' [, $iDir=-1 [, $iRetType=0 ,[$sDelim='0']]]]) ; Description: Recursive listing of files and/or folders ; Parameter(s): $sPath Basicpath of listing ('.' -current path, '..' -parent path) ; $sExt Extension for file selection '*' or -1 for all (Default) ; $iDir -1 Files+Folder(Default), 0 only Files, 1 only Folder ; optional: $iRetType 0 for Array, 1 for String as Return ; optional: $sDelim Delimiter for string return ; 0 -@CRLF (Default) 1 -@CR 2 -@LF 3 -';' 4 -'|' ; Return Value(s): Array (Default) or string with found pathes of files and/or folder ; Array[0] includes count of found files/folder ; Author(s): BugFix (bugfix@autoit.de) ;================================================================================================== Func _GetFilesFolder_Rekursiv($sPath, $sExt='*', $iDir=-1, $iRetType=0, $sDelim='0') Global $oFSO = ObjCreate('Scripting.FileSystemObject') Global $strFiles = '' Switch $sDelim Case '1' $sDelim = @CR Case '2' $sDelim = @LF Case '3' $sDelim = ';' Case '4' $sDelim = '|' Case Else $sDelim = @CRLF EndSwitch If ($iRetType < 0) Or ($iRetType > 1) Then $iRetType = 0 If $sExt = -1 Then $sExt = '*' If ($iDir < -1) Or ($iDir > 1) Then $iDir = -1 _ShowSubFolders($oFSO.GetFolder($sPath),$sExt,$iDir,$sDelim) If $iRetType = 0 Then Local $aOut $aOut = StringSplit(StringTrimRight($strFiles, StringLen($sDelim)), $sDelim, 1) If $aOut[1] = '' Then ReDim $aOut[1] $aOut[0] = 0 EndIf Return $aOut Else Return StringTrimRight($strFiles, StringLen($sDelim)) EndIf EndFunc Func _ShowSubFolders($Folder, $Ext='*', $Dir=-1, $Delim=@CRLF) If Not IsDeclared("strFiles") Then Global $strFiles = '' If ($Dir = -1) Or ($Dir = 0) Then For $file In $Folder.Files If $Ext <> '*' Then If StringRight($file.Name, StringLen($Ext)) = $Ext Then $strFiles &= $file.Path & $Delim Else $strFiles &= $file.Path & $Delim EndIf Next EndIf For $Subfolder In $Folder.SubFolders $Folder.SubFolders If ($Dir = -1) Or ($Dir = 1) Then $strFiles &= $Subfolder.Path & '' & $Delim _ShowSubFolders($Subfolder, $Ext, $Dir, $Delim) Next EndFunc ;==================================================================================================
Edited by bogQ, 28 July 2012 - 09:09 AM.
Posted 28 July 2012 - 09:42 AM
Edited by Melba23, 28 July 2012 - 10:04 AM.
Typo
Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display
RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
Posted 28 July 2012 - 12:01 PM
try it like this(test it on small amount of folders first)to se do it return array correctly
basically i think that BugFix func can be edited so that it return needed data with no FileFindFirstFile but i don't think that this nice func shud be edited at all for something as this that can change its use drasticly, but if you have time you can always try it yourself.#include $files = _FileGetFirstFiles(@DesktopDir&'\script',"*.txt")_ArrayDisplay($files,'before')For $x = 1 To $files[0]$split = StringSplit($files[$x], '.')If Not StringIsDigit(StringRight($split[$split[0]-1],1)) Then $split[$split[0]] = '0.'&$split[$split[0]] $files[$x] = _ArrayToString($split) EndIfNext_ArrayDisplay($files,'after')Func _FileGetFirstFiles($sDir,$searchString)Local $return[1],$search,$fileLocal $arr = _GetFilesFolder_Rekursiv($sDir,'*',1);~ _ArrayDisplay($arr,'tree_array')For $x = 1 To $arr[0] $search = FileFindFirstFile($arr[$x]&$searchString) If @error Then FileClose($search) Else While 1 $file = FileFindNextFile($search) If @error Then ExitLoop _ArrayAdd($return,$arr[$x]&$file) ExitLoop WEnd FileClose($search) EndIfNext$return[0] = UBound($return)-1If $return[0] Then Return $returnElse SetError(1)EndIfEndFunc;==================================================================================================; Function Name: _GetFilesFolder_Rekursiv($sPath [, $sExt='*' [, $iDir=-1 [, $iRetType=0 ,[$sDelim='0']]]]); Description: Recursive listing of files and/or folders; Parameter(s): $sPath Basicpath of listing ('.' -current path, '..' -parent path); $sExt Extension for file selection '*' or -1 for all (Default); $iDir -1 Files+Folder(Default), 0 only Files, 1 only Folder; optional: $iRetType 0 for Array, 1 for String as Return; optional: $sDelim Delimiter for string return; 0 -@CRLF (Default) 1 -@CR 2 -@LF 3 -';' 4 -'|'; Return Value(s): Array (Default) or string with found pathes of files and/or folder; Array[0] includes count of found files/folder; Author(s): BugFix (bugfix@autoit.de);==================================================================================================Func _GetFilesFolder_Rekursiv($sPath, $sExt='*', $iDir=-1, $iRetType=0, $sDelim='0')Global $oFSO = ObjCreate('Scripting.FileSystemObject')Global $strFiles = ''Switch $sDelim Case '1' $sDelim = @CR Case '2' $sDelim = @LF Case '3' $sDelim = ';' Case '4' $sDelim = '|' Case Else $sDelim = @CRLFEndSwitchIf ($iRetType < 0) Or ($iRetType > 1) Then $iRetType = 0If $sExt = -1 Then $sExt = '*'If ($iDir < -1) Or ($iDir > 1) Then $iDir = -1_ShowSubFolders($oFSO.GetFolder($sPath),$sExt,$iDir,$sDelim)If $iRetType = 0 Then Local $aOut $aOut = StringSplit(StringTrimRight($strFiles, StringLen($sDelim)), $sDelim, 1) If $aOut[1] = '' Then ReDim $aOut[1] $aOut[0] = 0 EndIf Return $aOutElse Return StringTrimRight($strFiles, StringLen($sDelim))EndIfEndFuncFunc _ShowSubFolders($Folder, $Ext='*', $Dir=-1, $Delim=@CRLF)If Not IsDeclared("strFiles") Then Global $strFiles = ''If ($Dir = -1) Or ($Dir = 0) Then For $file In $Folder.Files If $Ext <> '*' Then If StringRight($file.Name, StringLen($Ext)) = $Ext Then $strFiles &= $file.Path & $Delim Else $strFiles &= $file.Path & $Delim EndIf NextEndIfFor $Subfolder In $Folder.SubFolders $Folder.SubFolders If ($Dir = -1) Or ($Dir = 1) Then $strFiles &= $Subfolder.Path & '\' & $Delim _ShowSubFolders($Subfolder, $Ext, $Dir, $Delim)NextEndFunc;==================================================================================================
Edited by AHRIMANSEFID, 28 July 2012 - 12:03 PM.
Posted 28 July 2012 - 12:41 PM
Posted 28 July 2012 - 01:04 PM
Edited by czardas, 28 July 2012 - 01:05 PM.
Posted 28 July 2012 - 05:03 PM
Me Test Code but Not Working Run Send Me Error Line 727
Posted 29 July 2012 - 06:37 AM
Posted 29 July 2012 - 07:10 AM
AutoIt lacks a "FileRename" function.
Posted 29 July 2012 - 09:44 AM
Posted 29 July 2012 - 09:58 AM
Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display
RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
Posted 29 July 2012 - 12:32 PM
Yes it's always same and it's in .gif format.In your example it is the only one with digits at the end of the filename - is that always the case?
Posted 29 July 2012 - 12:49 PM
#include <RecFileListToArray.au3> #include <Array.au3> ; List all files and folders - add a trailing to get a added to folders $aList = _RecFileListToArray("N:Folder", "*.gif", 0, 1, 1, 2) ; Just for display _ArrayDisplay($aList) For $i = 1 To $aList[0] ; Ignore folders by checking for the trailing If StringRight($aList[$i], 1) <> "" Then ; Now see if there is no digit before the .gif extension If Not StringRegExp($aList[$i], ".*d.gif") Then ; We found a file that matches ConsoleWrite($aList[$i] & @CRLF) EndIf EndIf Next
Edited by Melba23, 29 July 2012 - 05:50 PM.
Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display
RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
Posted 30 July 2012 - 10:28 AM
Posted 30 July 2012 - 10:32 AM
That is not a lot of use. What does not work? What output do you get? Did you change the path to that you use?not work
Toast - Small GUIs which pop out of the Systray - Marquee - Scrolling tickertape GUIs
Scrollbars - Automatically sized scrollbars with a single command - GUIFrame - Subdivide GUIs into many adjustable frames
GUIExtender - Extend and retract multiple sections within a GUI - NoFocusLines - Remove the dotted focus lines from buttons, sliders, radios and checkboxes
ChooseFileFolder - Single and multiple selections from specified path tree structure - - Notify - Small notifications on the edge of the display
RecFileListToArray - An alternative to _FileListToArray with user-defined include/exclude masks, maximum recursion level, sorting and displayed path options
GUIListViewEx - Insert, delete, move, drag and sort ListView items
0 members, 0 guests, 0 anonymous users