Hello, I need to synchronize the directories on the local and remote computers using ftp, but with the condition that the script will run on windows with a minimum number of additional programs. Ideally, only with built-in tools like ftp (I don’t really want to use wget). Install the software on the server is not possible.

So far I have come up with such an algorithm of actions: 1. I write down (with my hands) the start of ftp commands with the server address, login, password, and transitions to the desired “root folder” on the remote server. 2. I generate a list of files that I currently have on the local computer by appending get to the beginning (newer could not get it to work). 3. I concatenate these files into a single scriptFile 4. Run ftp -v -n -s: scriptFile 5. I wait for execution and delete the converted scriptFile

There is the following problem. I have two folders that should not be written to the file in the second stage. .temp1 call them .temp1 and .temp2 . The server also has folders that I don't need. Let's call them upload and cache. At the same time, files that I do not have on the local computer constantly appear, but I would like to receive it.

I found the dir /AD /B /S "./" command, but it does not display what is necessary: ​​all files with paths relative to the root of the file system (C: \ dir.temp2 \ sample.txt). Well, it is impossible to exclude directories.

Then I turned to the forfiles /P . /S /M * /C "cmd /c echo get @relpath" command forfiles /P . /S /M * /C "cmd /c echo get @relpath" forfiles /P . /S /M * /C "cmd /c echo get @relpath" . In general, it already displays all that I need, but still can not ignore files. I don’t know if you can write some condition in it, so I found this way : go into folders and execute forfiles right there.

 @echo off for /D %%D in ("\dir\*.*") do ( if /I not "%%D"=="\dir\.temp1" ( chdir "%%D" forfiles /P . /S /M * /C "cmd /c echo get @relpath" cd ../ ) ) 

I do not really understand which way to move now. Tell me how to modify the script. Maybe I didn’t choose the right algorithm and it’s better to write promt , mget . And in general, experts, tell me if get ".\subdir\sample.txt" in ftp? Do not you need to go to the directory?

And one more situation, my addresses are now displayed like this: ".\subdir\sample.txt" , it seems to me that it is necessary to replace .\ ".\subdir\sample.txt" \ . I found only the way using the variable: set str=%str:find=replace% . Maybe something better to eat?

  • Or maybe you look in the direction of WSH? - Anton Shchyrov
  • @AntonShchyrov is a very good sentence, only I know even less about any of the languages ​​available in WSH. Probably, everything is cool and simple there, but unfortunately I don’t even know where to study, = ( - higimo
  • Msdn Believe, it will be much easier. And JScript - he is almost C - Anton Shchyrov

0