Jump to content

Recommended Posts

Posted (edited)

Hello Guys,

Well m working on script that will list the files from drive/folder and upload them to a server (ftp). em using

Melba23 UDF

'?do=embed' frameborder='0' data-embedContent>>

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

Local $aArray = _RecFileListToArray("F:", "*.PSD", 1, 1, 0, 2)
_FileWriteFromArray( @ScriptDir & "\list.txt" , $aArray, 1)

i want to upload file one by one on server by reading the file "list.txt" ..

Please help me out with this..

Thank You in advance. o:) o:) o:)

Edited by verma123
Posted

Also that UDF is included in the stable version as _FileListToArrayRec()

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Posted

JohnOne yes bro i knw how to upload file using ftp... with Ftp FilePut Function. but don't have any idea how to these one bt one by reading the file

Posted

Here's my take on your request. I don't have an FTP server I can test against so I hope at least this can give you some ideas.

#include <FTPEx.au3>
#include <File.au3>

Local $FTPServer = 'ftp.server.com'
Local $username = 'username'
Local $password = 'password'
Local $filePath = 'c:\filepath' ;Path to location of files to upload
Local $aFileList = _FileListToArray($filePath,"*",1) ;Array list of files in path alone

$Open = _FTP_Open('MyFTP Session')
$Conn = _FTP_Connect($Open, $FTPServer,$username,$password) ;Add other options as needed

For $i = 1 to $aFileList[0] - 1
    _FTP_FilePut($Conn,$aFileList[$i],'locationdir') ;tweak for correct destination location
    
Next
$FTPc = _FTP_Close($Open)

Though there is more hardcoded here than what I would normally do (username, password, path), I hope this can help. Most of the code is variations of what is in the AutoIT help file.

I see you also mention reading from a text file, is that a requirement? My approach above just reads the list into an array, eliminating the need for the text file. (Though I can see where you might have a need for the text file)

Posted (edited)

sup bro,

  ;-)  is that a pic of your server desktop? then that is a folder named PDF on your desktop?

Because your destination location is set to root "/"

  Other than that I can say what I always say... a lot can go wrong with an FTP transfer. It is usually one or 2 small mistakes in syntax or permissions or connectoins ...etc

which means keep tryin bro  B)

Bill

 

...spelling

Edited by l3ill
Posted

I dont know where you are wrong....

   Can you upload one file via Ftp FilePut Function? 

your answer - "Yes Bro"

  So use that info to upload all of them with the _FileListToArrayRec ( as sugg. bu guinness )

The code from gritts looks like a good start but as he mentioned there is some tweaking involved.

Get a small script and one file working then test and play until you get the code to do what you want.

Lots of playing and testing invlolved... for instance: one of these '/' in the wrong place and ....no transfer.

Show us some code that you have and what it is doing or NOT doing and go from there.

good luck!

Bill

Posted

OKay !!

here is what i have done yet !! with help you ! Guys !

#include <FTPEx.au3>

Local $sServer = 'server
Local $sUsername = 'myuser'
Local $sPass = 'pass'

Local $hOpen = _FTP_Open('MyFTP Control')
Local $hConn = _FTP_Connect($hOpen, $sServer, $sUsername, $sPass)
_FTP_FilePut ( $hConn, @ScriptDir & "/hello.pdf" , "/hello.pdf" ,0 ,0 )

with this code above i can upload the single pdf on server.

Question :

1. How to Upload multiple files with there orignal names on server. By Reading Files location from array like this:

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

Local $sDrives = DriveGetDrive ( "ALL" )
For $d = 1 to $sDrives[0] -1 
Next
Global $aFileList =  _RecFileListToArray( $sDrives[$dvi] , "*.png", 1, 1, 0, 2)
For $i = 1 to $aFileList[0]
MsgBox ( 16 , "Notice" , "Some Boxes" )
Next

If i change the code to this:

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

Global $aFileList =  _RecFileListToArray( "C:" , "*.png", 1, 1, 0, 2)
For $i = 1 to $aFileList[0]
  FileCopy ( $aFileList[$i] , "C:\Users\Terantula\Desktop" )
Next

it works i just removed the this part

Local $sDrives = DriveGetDrive ( "ALL" )
For $dvi = 1 to $sDrives[0]
_ArrayDisplay ( $sDrives[$dvi] , 1 )
Next

so overall with my code i want to upload my all PDF , PSD files to ftp server by searching files in whole pc drives.

Hope you guys uderstood what em trying to say !

:sweating: :sweating: :sweating: :sweating: :sweating:

Posted

That should be easy, especially when you already success upload 1 file to the FTP server.

The steps are:

1. Search all the files that match the criterias (*.pdf, *.psd) from all (local?) harddrive.

2. Loop using For..Next and upload those files, eg:

For $a = 0 to Ubound($file_list)-1
    ; upload here
Next

 

For step no 1, I'm a big fan of AZJIO's File Operation UDF found >here

Posted (edited)

m not that much hard coder !! please can explain little more cody ?

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

Local $sDrives = DriveGetDrive ( "ALL" )
For $dvi = 1 to $sDrives[0]
_ArrayDisplay ( $sDrives[$dvi] , 1 )
Next
Global $aFileList =  _RecFileListToArray( $sDrives[$dvi] , "*.png", 1, 1, 0, 2)
For $i = 0 to Ubound($aFileList)-1     
   _FTP_FilePut ( $hConn, $aFileList[$i] , "" ,0 ,0 )
Next

its not working :(

Edited by verma123
Posted

If you understand for ... next loop and  if you spend some time to see AZJIO's File Operation UDF I told you above,

you will get it done :)

If you dont, please post your code using that UDF, somebody will help you.

Posted

Forget your FTP stuff for now.

Concentrate on making working code that searches your whole computer for the files you want.

Post all that you try, along with error checking.

Put some real effort in, the more you do that, the more willing assistance you will get.

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

  • 2 weeks later...
Posted (edited)

JohnOne brother

Finally its working ... This will search specific file extention in whole system depends on "FIXED" or "ALL" and shows searched files in

_ArrayDisplay
#include <File.au3>
#include <Array.au3>
#include "RecFileListToArray.au3"

Local $sDrives = DriveGetDrive ( "FIXED" )
for $i = 1 to  $sDrives[0]
Global $aFileList =  _RecFileListToArray( $sDrives[$i] , "*.au3", 1, 1, 0, 2)
_ArrayDisplay ( $aFileList )
Next
MsgBox ( -1 , "All Done", "Search completed" )

Thanks to all Specially :

michaelslamet , JohnOne, l3ill and gritts

:sorcerer: :sorcerer: :sorcerer: :sorcerer: :sorcerer:

JohnOne Now can we move to Uploading Searched files to FTP Server? o:) o:)

Edited by verma123

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...