lettura nomi file

« Older   Newer »
  Share  
darkphoinix
CAT_IMG Posted on 18/7/2017, 16:55     +1   -1




Ciao volevo leggere una dir con dei file con nomi composti da: anno, mese, giorno, ora,minuti,secondi
(es 2017-01-02_10-30-11 )
Vorrei riuscire a leggere il nome dei file e poi creare delle dir con anno,mese,giorno e spostando i file con la stessa data all'interno! mi serve un commando per leggere i nomi dei file e uno per poter estrapolare i dati che mi servono.
Ho prima guardato la guida cercando :file ,getfile, filegetname ma nulla.
Poi su google ho trovato voi cercando qualche esempio.
Vi ringrazio per la mano!
 
Top
Shirotaiku
CAT_IMG Posted on 19/7/2017, 09:21     +1   -1




Ciao, praticamente vai ad usare FileFindFirstFile(Dir),
che ti da il nome del primo file in quella cartella ,
ed usi FileFindNextFile(HandleFileFindFirstFile) per spostarti e trovare il 2 / 3 / ecc.. file.
Ti lascio un udf che uso praticamente sempre.
Devi usare _Search_File(NomeDir) e ti ritorna un array ove lo $array[0] č uguale al numero di elementi dello stesso, il secondo parametro riguarda l'estenzione Es. Tutti i file *.* solo file rar *.rar e cosi via.
CODICE
#cs ----------------------------------------------------------------------------

AutoIt Version: 3.3.14.2
Author:       Shirotaiku

#ce ----------------------------------------------------------------------------
#include-once

#cs
$Dir=@ScriptDir
$file=_Search_File($Dir,"*.*")
for $a=1 to $file[0]
Msgbox(64,"Posizione "&$a,"Nome File"&$file[$a])
next
exit
#ce

Func _Search_File($Directory,$Type)
       $hSearch=FileFindFirstFile(FixDir($Directory)&$Type)
       If $hSearch = -1 Then Return SetError(1,0,"Nessun file trovato!!")
       Dim $hFindFile[2]
       $move=1
       While 1
               $hFindFile[$move]=FileFindNextFile($hSearch)
               If @error Then ExitLoop
               If @extended=0 Then
               ReDim $hFindFile[UBound($hFindFile)+1]
               $move+=1
               EndIf
       WEnd
       ReDim $hFindFile[UBound($hFindFile)-1]
       $hFindFile[0]=$move-1
       Return $hFindFile
EndFunc



Func _Search_Dir($Directory)
       $hSearch=FileFindFirstFile(FixDir($Directory)&"*.*")
       If $hSearch = -1 Then Return SetError(1,0,"Nessuna Directory trovata!!")
       Dim $hFindFile[2]
       $move=1
       While 1
               $hFindFile[$move]=FileFindNextFile($hSearch)
               If @error Then ExitLoop
               If @extended=1 Then
               ReDim $hFindFile[UBound($hFindFile)+1]
               $move+=1
               EndIf
       WEnd
       ReDim $hFindFile[UBound($hFindFile)-1]
       $hFindFile[0]=$move-1
       Return $hFindFile
EndFunc






Func FixDir($Directory)
       $Predir = StringRight($Directory, 1)
       If $Predir = "\" Or $Predir = "/" Then
               Return $Directory
       Else
               Return $Directory & '\'
       EndIf
EndFunc   ;==>FixDir
 
Top
darkphoinix
CAT_IMG Posted on 24/7/2017, 00:04     +1   -1




ciao grazie! ho usato la funzione _FileListToArray alla fine.
adesso ho un po di problemi con la progress bar ma aprirņ un'altro topic per risolverlo
 
Top
2 replies since 18/7/2017, 16:55   43 views
  Share