简体   繁体   English

将数据从一个文件复制到另一个文件不起作用(批处理脚本)

[英]Copy data From one file to another file doesn't work (Batch Script)

First I read the path from another file and stored it into "c" variable But Path contains by "C" variable has space like ~~~ E:\\my folder\\first.txt首先,我从另一个文件中读取路径并将其存储到“c”变量中,但是“C”变量包含的路径具有像~~~ E:\\my folder\\first.txt 这样的空间

When I try batch script to copy data from one file(file path specified by c variable) into another file, it doesn't work当我尝试批处理脚本将数据从一个文件(由 c 变量指定的文件路径)复制到另一个文件时,它不起作用

COPY %c% E:\shubham\second.txt

I also tried with double quotes:我也试过用双引号:

COPY "%c%" "E:\shubham\second.txt"

doesn't work不起作用

Here is the full Script:这是完整的脚本:

@echo on SetLocal EnableDelayedExpansion
for /F "delims=" %%i in (E:\WritePath.txt) do set c=!content! %%i echo %c% COPY %c% E:\shubham\second.txt

You are not setting the variable correctly.您没有正确设置变量。 it should be set c=%%i它应该set c=%%i

but you do not need to set the variables here, you can use the metavariable as is.但是您不需要在此处设置变量,您可以按原样使用元变量。

@echo off
Setlocal enabledelayedexpansion
for /F "delims=" %%a in (E:\WritePath.txt) (
    Set var=!var! %%a
    echo !var!
)
echo !var! >>"E:\shubham\second.txt"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么此批处理脚本不起作用? 从文件读取行 - Why doesn't this batch script work? Reading lines from file 如何使用批处理脚本将文件从一台Windows计算机复制到特定驱动器中的另一台Windows计算机? - How to copy the file from one windows machine to another windows machine in a particular drive using batch script? 批处理脚本可根据上次修改日期或创建日期将文件从一个网络共享复制到另一个网络共享 - Batch script to copy a file from one network share to another based on lastmodified or creation date 将元数据从一个文件批量复制到另一个文件(EXIFTOOL) - Batch copy metadata from one file to another (EXIFTOOL) 批处理文件可将文件从一个目录复制到另一个目录 - Batch file to copy files from one directory to another 如何在批处理文件中将选定的文件从一个文件夹复制到另一个文件夹? - How to copy selected files from one folder to another in Batch file? 批处理文件不插入来自另一个文件的文本 - Batch file doesn't insert text from another file 批处理:将一个txt文件的内容复制到另一个 - Batch: copy content of one txt file into another 运行cmd命令工作,但从批处理文件运行不 - Run cmd command work but run from batch file doesn't 批处理脚本从文件夹复制最新文件 - Batch Script to copy latest file from Folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM