Move from FTP and count in Target folder automated

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
aaksar
Posts: 105
Joined: 17 Nov 2012 05:13

Re: Move from FTP and count in Target folder automated

#31 Post by aaksar » 27 Nov 2012 03:33

Code: Select all

FTP_SERVER;USER_NAME;PASSWORD;MAX_NUMBER_TO_DOWNLOAD;LOCAL_FOLDER;REMOTE_FOLDER
ftp.us.abcder.com;Ftp0014;^^abCDF3;3;C:\folder\;2 ABC Tables


above is the loc.

there are 2 files in "2 ABC Tables"folder, but i think due to space in folder its not be able to do CD

and in the Command_2.ftp is showing
get folder name
get folder name 2
get folder name 3
get ntuser.pol


but it should get the file which are inside the dir, and now its not moving
ntuser.pol file.
i have told them to create 1 folder and give me all the files in 1 folder without making subdir.

but when i m giving folder name in ftp.set file its not picking.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Move from FTP and count in Target folder automated

#32 Post by abc0502 » 27 Nov 2012 04:26

i'm making now a folder in my ftp and will test again.

Edit:
OK, sorry this is my bad, when i removed double quotes from
around the username and the password to prevent any errors in them, and also removed it from around the %~6 and %~5 by mistake.

I updated the previous code, test it again now.

aaksar
Posts: 105
Joined: 17 Nov 2012 05:13

Re: Move from FTP and count in Target folder automated

#33 Post by aaksar » 27 Nov 2012 05:27

now when i am giving folder name in remote folder, its transferring the files, but when i am not giveing any folder name in remote folder, it's treating all the folder name in FTP loc as file and doing
get folder 1
get folder 2

now 2nd thing, its doing get filename, but the file is not coming in target folder,

aaksar
Posts: 105
Joined: 17 Nov 2012 05:13

Re: Move from FTP and count in Target folder automated

#34 Post by aaksar » 27 Nov 2012 05:33

ftp> open ftp.us.abc.com
User (ftp.us.abc.com:(none)):

ftp> lcd "D:\folder\"
\folder\: File not found
ftp> cd "1 Support Tables"
ftp> get "ABC"
ftp> get "ABCD"
ftp> get "ABCDE"
ftp> get "ABCder"
ftp> get "ABCthjj"
ftp> get "ABCeereee"
ftp> get "ABCddddddx"
ftp> get "ABCdddddd"
ftp> get "Temp"
Error opening local file Temp.
> Temp:Unknown error number
ftp> disconnect
ftp> Bye
The system cannot find the path specified.
Could Not Find D:\folder\*.zip

aaksar
Posts: 105
Joined: 17 Nov 2012 05:13

Re: Move from FTP and count in Target folder automated

#35 Post by aaksar » 27 Nov 2012 05:35

FTP_2 file
lcd "D:\folder\"
cd "1 abc Tables"
get "176A_ABC"
get "189A_ABCD"
get "asfggg"

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Move from FTP and count in Target folder automated

#36 Post by abc0502 » 27 Nov 2012 05:38

now when i am giving folder name in remote folder, its transferring the files, but when i am not giveing any folder name in remote folder, it's treating all the folder name in FTP loc as file and doing
get folder 1
get folder 2

you have to give the batch the directory where you will download files from, so when you don't give hime a remote folder you till him to work on the parent directory which is the main directory when you log in.
IF your files inside a folder you must give the batch the location even if it was a folder inside a folder like "2 ABC Table\test2"

about the 2nd thing, does the file being downloaded in your hdd but in wrong location or it just display get filename and not downloading at all.
Note that the folder must exist in your hdd "local folder"

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Move from FTP and count in Target folder automated

#37 Post by abc0502 » 27 Nov 2012 05:40

tp> lcd "D:\folder\"
\folder\: File not found
ftp> cd "1 Support Tables

that's why it is being downloaded in wrong location, the folder D:\folder dosn't exist in system

You must create the folder, the batch will not create it for you.


Edit
BTW, temp is a folder when downloading it, it will create a zero byte file in the location and by doing that when the batch count the files it will get wrong file numbers.

aaksar
Posts: 105
Joined: 17 Nov 2012 05:13

Re: Move from FTP and count in Target folder automated

#38 Post by aaksar » 27 Nov 2012 05:57

Folder is there actually all the 3 script files are in d:\folder\

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Move from FTP and count in Target folder automated

#39 Post by abc0502 » 27 Nov 2012 06:06

ok, try to remove the last slash "\" after the folder name from the ftp setting file
maybe ftp dosn't recognize the windows structure and consider the slash as a part of the folder name.

aaksar
Posts: 105
Joined: 17 Nov 2012 05:13

Re: Move from FTP and count in Target folder automated

#40 Post by aaksar » 27 Nov 2012 06:23

now its copying the file after removing \
Thanks buddy

i am giving file count 15 , but my files are only 12, so after copying 12 files it should again pole the ftp loc for remaining file, but after copying files its coming out and not polling for remaining 3 files.

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Move from FTP and count in Target folder automated

#41 Post by abc0502 » 27 Nov 2012 06:29

So your files that is supposed to be downloaded is 15 and it only download 12 then exist.

Does it sownload those 12 in one start "after you start the batch for first time it download 12" and then it exit ?

Edit,
I just tested it, if there is a folder with your files and when the batch try to download it generate error and that error make the batch close without continue any other commands.

If these folder has a permanent names and don't change from time to time, maybe i can make the batch skip them.

aaksar
Posts: 105
Joined: 17 Nov 2012 05:13

Re: Move from FTP and count in Target folder automated

#42 Post by aaksar » 27 Nov 2012 06:44

for testing purpose i have given count of files 15, but in actual its 11, and in the same folder there is another folder "temp" so it tries to
get temp
but won't successful as its folder...

and is there any window default prgrm for zip as i dont hv 7zip, so when i m copying .zip files its copying but dont extract due to 7zip , and at the end it deleting all the zip file.

aaksar
Posts: 105
Joined: 17 Nov 2012 05:13

Re: Move from FTP and count in Target folder automated

#43 Post by aaksar » 27 Nov 2012 06:49

and pls mark where r u giving get command tyo move files

abc0502
Posts: 1007
Joined: 26 Oct 2011 22:38
Location: Egypt

Re: Move from FTP and count in Target folder automated

#44 Post by abc0502 » 27 Nov 2012 06:56

The get command is written using the for loop, and write that command to the 2nd ftp command file
:: get the all file names that dosn't exist in the local folder and put then in ftp command file 2 to be downloaded
For /F "tokens=* delims=" %%a in ('Type "%temp%\%~7\server_list.lst"') Do (
IF not exist "%~5\%%a" echo get %%a >>"%temp%\%~7\commands_2.ftp"
)


it doesn't matter, as long as the files in your local folder less than the one you gave, it should keep looping.
but as i said it's because of the folder, when try to download it get error and exit.
that's why i told you in previous post to have all files in one folder alone without other folders.
does this temp folder always exist ?


and about the 7z, what programs do you have?
there was some one asking about something like that i will check it.

aaksar
Posts: 105
Joined: 17 Nov 2012 05:13

Re: Move from FTP and count in Target folder automated

#45 Post by aaksar » 27 Nov 2012 07:10

now i m giving the path of the folder which contains only 3 zip files, and i have given file count 15, but after copying file it came out from script and not poling for remaining files.

for zip its window default i think.

Post Reply