Jump to content

Recommended Posts

Posted

Hello i Writng a code that will Check if a removal media is in Status "Ready"

then copy the files to a specific directory.

so far i can handel it by my self but

what i want to know is if there is any way to tell autoit not copy files with over then 30 CHR file name?

Best Regards

Krikov

[topic="63488"][font="Arial"]Krikov Tray Quick Menu[/font][/topic]

Posted (edited)

Try this code to check the length of filename and if the length is equal or over 30, the file will not be copied.

; don't forget include this.. 
#include <file.au3>
Dim $szDrive, $szDir, $szFName, $szExt
; splits a path into the drive, directory, file name and file extension parts
$TestPath = _PathSplit($PathToFile, $szDrive, $szDir, $szFName, $szExt)
; returns the number of characters in a string (filename in this case)
$StrLen=StringLen ($szFName) 
If $StrLen <= 30 Then
 ; your copy operation
 ; ...
EndIf
Edited by odklizec
Posted

Hello i Writng a code that will Check if a removal media is in Status "Ready"

then copy the files to a specific directory.

so far i can handel it by my self but

what i want to know is if there is any way to tell autoit not copy files with over then 30 CHR file name?

Best Regards

Krikov

Here is code snippet:

#include <File.au3>
    #include <Array.au3>

    $FileList=_FileListToArray('A:\',"*.*",1)
    If @Error=0 Then
        _ArraySort($FileList,0,1)
;~      _ArrayDisplay($FileList,'names')
        For $i = 1 to UBound($FileList) - 1
            $name = FileList[$i]
            If StringLen($name) < 31 Then
               ; do what you want ...
            EndIf
        Next
    EndIf

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
×
×
  • Create New...