Sign in to follow this  
Followers 0
PcExpert

Check if remote file exists

8 posts in this topic

Hello,

Is it possible to check if a remote file exists?

Thanks,

PcExpert

Share this post


Link to post
Share on other sites



#include <file.au3>

;the file you want to search for
$find = "test.txt"

;where E: is the remote drive you want to check
$rDrive = DriveMapGet("E:") & "\"

;change the working directory
FileChangeDir( $rDrive )

;get the first file
$search = FileFindFirstFile( "*.*" )

If $search = -1 Then
    MsgBox( 0, "ERROR!", "There are no files or could not connect to remote directory" )
EndIf

While 1
    $file = FileFindNextFile( $search )
    
    If @error Then
        MsgBox( 0, "Failure", "The file was not found in the remote directory" )
        ExitLoop
    EndIf
    
    If $file = $find Then
        MsgBox( 0, "Success", "The file exists in the remote directory " & $rDrive )
        EndLoop
    EndIf
WEnd

FileClose( $search )

Hope that helps...


_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Share this post


Link to post
Share on other sites

oow, sorry that I didn't told that. I want to check if a file exists in the internet for example: I want to check if www.mytestwebsite.com/mytestscript.au3.

Thanks,

PcExpert

Share this post


Link to post
Share on other sites

Either of these should be able to tell you, what I would say is that if the webhost displays a html "file not found" page then inetget will download this page, so I suggest you open the file and check a line of text within the file to ensure it isn't a HTML "file not found" page you just downloaded

Downloads a file from the internet using the http or ftp protocol.

InetGet ( "URL" [,"filename" [, reload [, background]]] )

Returns the size (in bytes) of a file located on the internet.

InetGetSize ( "URL" )

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

It's an exe file on my own home FTP Server. after the minute it returns the filesize

Edited by PcExpert

Share this post


Link to post
Share on other sites

If its on ur home ftp server can't you jsut run a script on the server and have it email you the size. Or map a network drive to the drive running the ftp server and run the script posted above?


_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Share this post


Link to post
Share on other sites

Try this

$size = InetGetSize("http://www.comp-sos.co.uk/download/test.exe")
if $size = 0 Then
MsgBox(0, "", "File does not exist")
EndIf


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

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