复制文件/w名称中的空格 [英] Copy Files /w Spaces In Name

查看:58
本文介绍了复制文件/w名称中的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码是

SET usb="%CD%\Dokument\%USERNAME%\"
mkdir %usb%
for /R "C:\Users\%USERNAME%\" %%f in (*.docx) do copy %%f %CD%\Document\%USERNAME%\

,它有效,但不适用于名称中带有空格的文件(.docx).我尝试用引号和其他代码样式/方法修复它,但无法解决.(我是DOS新手).我该如何解决?

and it works, but not for files (.docx) with spaces in their name. I've tried fixing it with quotes, and different code styles/methods, but can't solve it. (I'm new to DOS). How can I solve this?

还是有更好的代码将所有扩展名为.docx的文件从计算机复制到另一目录/usb?

Or is there a better code to copy all the files with .docx extension from a computer to another directory/usb?

推荐答案

您需要引用包含空格的文件路径,即 copy"%% f"

You need to quote file paths containing spaces, i.e. copy "%%f"

这可能会做您想要的事情:

This may do what you wanted:

Set "USB=%~dp0Dokument\%USERNAME%"
If Not Exist "%USB%\" MD "%USB%" 2>&1||Exit/B
For /F "Delims=" %%A IN ('Where/R "%USERPROFILE%" *.docx'
) Do Copy/Y "%%A" "%USB%">Nul

这篇关于复制文件/w名称中的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆