中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-10 22:00
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » [Help] How to modify specified content to achieve FTP upload of specified files
Printable Version  2,464 / 6
Floor1 379061296 Posted 2008-12-07 08:13
新手上路 Posts 10 Credits 11
```batch
set route=%cd%
set ravel=
set /p ravel=Please enter the file to upload:
set "ravel=%ravel:"=%"

rem Modify ftp.txt to replace c:\1.txt with the obtained variable
for /f "delims=" %%a in ('type ftp.txt') do (
set "line=%%a"
setlocal enabledelayedexpansion
set "line=!line:c:\1.txt=!ravel!"
echo(!line!>>new_ftp.txt
endlocal
)
move /y new_ftp.txt ftp.txt>nul
```


Transferred from DOS Troubleshooting & Problem Discussion (Q&A Room)
Please post in the corresponding section in the future.
——Administrator


───────────────── Moderation Record ─────────────────
Performed by: HAT
Operation: Added search keywords in the post title; added code tags to the code
Description: The original title "How to modify specified content" was not conducive to forum search
Punishment: Deducted 2 points
Tip: It is recommended to read the following posts
{1415}The Wisdom of Asking Questions
{7326}Essential Guidelines for Forum Newcomers, Basic Behavior Norms for Everyone
{22703}Please Don't Be an Impatient Person
{32667}Those Who Can't Even Write a Clear Title, Wake Up!
{32825}This Section Severely Rectifies Poor-quality Posts
───────────────── Moderation Record ─────────────────


[ Last edited by HAT on 2008-12-9 at 09:40 ]
Floor2 HAT Posted 2008-12-07 12:00
版主 Posts 5,017 Credits 9,023
It is suggested to ask questions in the batch processing room next time
Floor3 379061296 Posted 2008-12-09 00:49
新手上路 Posts 10 Credits 11
Floor4 exzzz Posted 2008-12-09 10:32
初级用户 Posts 167 Credits 194
Is this okay?



Note that I added an extra space after the password; if there's no space, it will get stuck there.

[ Last edited by exzzz on 2008-12-9 at 10:34 ]
Floor5 HAT Posted 2008-12-09 10:46
版主 Posts 5,017 Credits 9,023
```
@echo off
set /p ravel=Please enter the file to upload:
set "ravel=%ravel:"=%"
>ftp.txt echo open 192.168.0.13
>>ftp.txt echo 123
>>ftp.txt echo 123
>>ftp.txt echo cd wwwroot
>>ftp.txt echo put "%ravel%"
>>ftp.txt echo bye
start ftp -v -i -s:"%ftpFile%"
```
Floor6 exzzz Posted 2008-12-09 11:52
初级用户 Posts 167 Credits 194
set "ravel=%ravel:"=%"

Does the HAT moderator mean that this sentence refers to using the set command to remove the spaces in the variable ravel?
I saw in set /? that there is such a passage:

Environment variable substitution has been enhanced as follows:

%PATH:str1=str2%

This will expand the PATH environment variable, replacing each "str1" in the expanded result with "str2"
To effectively remove all "str1" from the expanded result, "str2" can be empty.

Then what is the effect of "str2 can be empty."? I tested it, and the variable doesn't seem to change?
Floor7 HAT Posted 2008-12-09 12:31
版主 Posts 5,017 Credits 9,023
The landlord means to delete the double quotes that the user may input to avoid causing errors in the subsequent commands.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023