indikad
asked on
DOS batch command help needed with ftp
what I am trying to do is
1 .connect to ftp
2. copy all files in a folder called "source"
3. place a copy of the files in a "Picked" folder
4. finally delete original files in "source"
I do this by using a batch file that calls a script file called GetFiles.txt
The calling batch file has following commands
GetFiles.txt has following commands
My script works for all 3 steps above. The step 4 fails. ( Line 13 ) - it does not do anything
I dont want to use mdelete *.* since I need to delete only the files I copied ( just in case some files did not get copied I want to keep them in source)
so I have implemented the following line for step 4 above ( but it fails )
1 .connect to ftp
2. copy all files in a folder called "source"
3. place a copy of the files in a "Picked" folder
4. finally delete original files in "source"
I do this by using a batch file that calls a script file called GetFiles.txt
The calling batch file has following commands
@Echo off
cd C:\FTPTest
ftp -v -w:2000000 -s:getfiles.txt
GetFiles.txt has following commands
prompt
open <ftp address>
username
password
cd Source
binary
lcd C:\Destination
mget *.*
lcd C:\Destination
cd ..
cd Picked
mput *.*
for /f %%a IN ('dir /b C:\Destination\*.*') do delete %%a
bye
My script works for all 3 steps above. The step 4 fails. ( Line 13 ) - it does not do anything
I dont want to use mdelete *.* since I need to delete only the files I copied ( just in case some files did not get copied I want to keep them in source)
so I have implemented the following line for step 4 above ( but it fails )
for /f %%a IN ('dir /b C:\Destination\*.*') do delete %%a
Hi Indikad,
Please try the following,
On the 13 line, put the following command
dir /b C:\Destination >>c:\Destination\list.txt
on the line 14, put the following command
for /F %%A in (c:\destination\list.txt) do (del c:\destination\%%A)
on the line 15, put the command : bye
Please test and let me know if it worked.
Please try the following,
On the 13 line, put the following command
dir /b C:\Destination >>c:\Destination\list.txt
on the line 14, put the following command
for /F %%A in (c:\destination\list.txt) do (del c:\destination\%%A)
on the line 15, put the command : bye
Please test and let me know if it worked.
ASKER
Hi ren20atom,
Thanks for your attention.
what is list.txt ?
also del does not work in thisn instance since - I am deleting files in a ftp folder.
Hi , billprew - at this moment I am bit reluctant to have another 3rdPart FTP client on the server. But thanks anyway for the tip.
Thanks for your attention.
what is list.txt ?
also del does not work in thisn instance since - I am deleting files in a ftp folder.
Hi , billprew - at this moment I am bit reluctant to have another 3rdPart FTP client on the server. But thanks anyway for the tip.
Does the c:\destination folder get cleaned out after each xfer, or will it build up with more and more files over time? If the latter then doing a DEL in ftp for each of those will grow beyond the files transferred in the most recent batch and become inefficient.
If the files do get moved out of there after each xfer then I have an approach that will work, but it will result in a good bit more bat code.
~bp
If the files do get moved out of there after each xfer then I have an approach that will work, but it will result in a good bit more bat code.
~bp
ASKER
Yes. Destination folder , will get flushed to a seperate folder within the local server. I just have not implemented that yet.
Thanks.
Thanks.
ASKER
billprew: , do you have the solution please ?
Working it...
~bp
~bp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks I will try now, and let you know.
ASKER
Works perfectly exactly the way I want.
Appreciate your time, this is worth 1000 points given the situation.
Thanks.
Appreciate your time, this is worth 1000 points given the situation.
Thanks.
ASKER
Thumbs Up!
ASKER
for anyone else using this code - make sure to have a CR / LF after the last line of the delfiles.cpy
So glad that was useful, and thanks for the kind words, and the grade.
~bp
~bp
You could make this a LOT simpler by using NCFTPGET (link below) with the -DD option, it will transfer the files to your pc, and then delete them from the server if successful, all automatically. And no control file needed, all options and parms are passed tight in on the command line. Great tool, and free.
http://www.ncftp.com/ncftp/
~bp