Sign in to follow this  
Followers 0
tasemu

A littlle help with FileCopy please

7 posts in this topic

hey i wanna use FileCopy in my script, but my source is in a folder that has a different name for each computer. is there any methods i could use to open that folder. it is also the only folder in there, so maybe somehow i can just make it choose the first folder it finds in that directory or something?

any help would be much appreciated.

thanks mate


[IMG]http://i432.photobucket.com/albums/qq50/tasemu/tasemu_sig.jpg[/IMG]

Share this post


Link to post
Share on other sites



I would have a look in the help file for FileFindFirstFile / FileFindNextFile / FileClose to get the first file. For every file I find I would use FileGetAttrib to check if it's a directory. If yes then start copying.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

hey i wanna use FileCopy in my script, but my source is in a folder that has a different name for each computer. is there any methods i could use to open that folder. it is also the only folder in there, so maybe somehow i can just make it choose the first folder it finds in that directory or something?

any help would be much appreciated.

thanks mate

Maybe this will help ?(Findfirstfile()/FindNextfile() functions can do this for you) :)

http://www.autoitscript.com/forum/index.php?showtopic=90545&start=0&p=651141&hl=findfirst%20file&fromsearch=1&#entry651141

Share this post


Link to post
Share on other sites

cool, thanks alot. but i need to find the first directory, i got the file name :)


[IMG]http://i432.photobucket.com/albums/qq50/tasemu/tasemu_sig.jpg[/IMG]

Share this post


Link to post
Share on other sites

cool, thanks alot. but i need to find the first directory, i got the file name :)

Oh yes it does return directories when you use *.*

You have to use FileGetAttrib() function on the returned name of FindNextFile to check if its FileGetAttrib() return has "D" in it. You can see details of these functions in AutoIT help.

Share this post


Link to post
Share on other sites

This should return the first directory in the Start Directory:

; Shows the filenames of all files in the current directory.
$StartDir = "C:\"
$search = FileFindFirstFile($StartDir & "*.*")  

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    ; Find next file in directory
    $file = FileFindNextFile($search)
    If @error Then ExitLoop
    If StringInStr(FileGetAttrib($StartDir & "\" & $file),"D") > 0 Then
        MsgBox(4096, "First Directory is: ", $file)
        ExitLoop
    EndIf
WEnd
FileClose($search)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Well if it didn't have to be entirely automatic you could do FileOpenDialog or FileSelectFolder.

Probably not what you are looking for but thought they should be referenced just in case.


"Human kind cannot gain anything without first giving something in return, to obtain; something of equal value must be lost."The Help File is truly your friend.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0