.bat文件从一个目录移动多个文件到另一个和重命名覆盖,而不是 [英] .bat file to move multiple files from one directory to another and rename instead of overwriting

查看:1943
本文介绍了.bat文件从一个目录移动多个文件到另一个和重命名覆盖,而不是的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

原谅我,如果这是一个简单的问题,但我已经练出来了几年!
我创建工作.bat文件,将要求我的所有文件从一个目录移动到另一个,如果任何冲突出现时,将日期添加到文件名,而不是覆盖它。总而言之,我想保留的所有文件,即使它们是重复的。 TIA的任何帮助!


解决方案

  MDC:\\ NewFolderCD%USERPROFILE%\\桌面FOR / Fdelims =%%的A('DIR /广告/ B%USERPROFILE%\\桌面')做,如果不存在C:\\ NewFolder \\ %% A(副本%% AC:\\ NewFolder \\ %% A)否则拷贝%% AC:\\ NewFolder \\ %% A%日期:/ =%

这丑陋,但它的工作原理,应该让你开始。参见 DIR /?为/?如果/?。注意:您要更改目录为它工作。

Forgive me if this is a simple question, but I've been out of practice for a few years! I am creating a .bat file at work that will require me to move all files from one directory to another and if any conflicts arise, to add the date to the filename instead of overwriting it. All in all, I want to keep every file, even if they are duplicates. TIA for any help!

解决方案

MD "C:\NewFolder"

CD "%userprofile%\desktop"

For /f "delims=" %%A in ('dir /a-d /b "%userprofile%\desktop"') do If not exist C:\NewFolder\%%A (copy "%%A" "C:\NewFolder\%%A") Else copy "%%A" "C:\NewFolder\%%A%date:/=%"

It ugly but it works and should get you started. See dir /?, for /?, and if /?. Note you have to change directories for it to work.

这篇关于.bat文件从一个目录移动多个文件到另一个和重命名覆盖,而不是的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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