使用MOVE或Robocopy使用可变源和目标移动文件 [英] Move Files with MOVE or Robocopy with a variable source and destination

查看:259
本文介绍了使用MOVE或Robocopy使用可变源和目标移动文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好



我需要将一个目录中的所有文件移动到另一个目录,并在发生错误时知道路径



我有两个简单的批处理文件:


带有移动工作的批处理文件中的


移动%1%2 



但是在robocopy中:

 robocopy%1% 2 



不起作用



有什么建议吗?



i需要robocopy,因为日志的输出向我发送了一个有错误的路径而且移动不是



i有两个简单的批处理文件



1.

 move%1%2>> D:\ test\log_good.txt 2>> D:\ test\log_error.txt 



ITS工作但日志不显示路径



这是我的简单剧本及其作品!但我需要在日志中看到源和目标路径

目前log_good是:1个文件移动



和log_errors是:

系统找不到指定的文件。 

进程无法访问该文件,因为它正由另一个进程使用。



我需要知道错误发生在哪条路径但是我不知道如何在我的日志中设置变量%1(我的来源)和%2(我的目的地)



2.



在这种情况下:

 robocopy%1%2 / MOV /LOG+:D:\test\mueve.txt



不起作用我的日志显示路径但不移动文件且权限正确...

 ---------------------------------------------- --------------------------------- 
ROBOCOPY :: Windows强大的文件复制
- -------------------------------------------------- ----------------------------

发起时间:8月19日星期三12:40:07 2015

来源:\\diva-disk.mam \tvsa_inter\discos-duros_rz \prueba_mueve_tmp \ MARIA_LA_DEL_BARRIO-130-201002232705_DV50_3_prueba_mueve.avi \
Dest: \\diva-disk.mam \tvsa_inter\discos-duros_rz\prueba_mueve \

文件:*。*

选项:*。* / COPY :DAT / MOVE / R:1000000 / W:30

------------------------------ ------------------------------------------------

2015/08/19 12:40:07 ERROR 267(0x0000010B)访问源目录\\diva-disk.mam \tvsa_inter\discos-duros_rz \prueba_mueve_tmp \ MARIA_LA_DEL_BARRIO-130- 201002232705_DV50_3_prueba_mueve.avi \
目录名无效。

解决方案

对于robocopy,源和目标都必须是目录。您正在将路径传递给文件,并且robocopy正确地告诉您它不是目录。



要传输特定文件,请使用 robocopy source_dir destination_dir文件。例如:

 robocopy \\diva-disk.mam \tvsa_inter\discos-duros_rz \ prueba_mueve_tmp \\diva-disk.mam \\ \\ tvsa_inter\discos-duros_rz\prueba_mueve MARIA_LA_DEL_BARRIO-130-201002232705_DV50_3_prueba_mueve.avi / MOV /LOG+:D:\test\mueve.txt 





要在批处理文件中使用它,请使用以下三个参数:

 robocopy%1%2%3 / MOV / LOG +:D:\ test \ mueve.txt 





如果调用批处理文件的应用程序无法单独传递目录和文件名,那么你将会需要在批处理文件中执行此操作。谷歌找到了这个 [ ^ ],这似乎有效:

< pre lang =plain> @ echo off

对于%% A %1执行
设置文件夹= %% ~dpA
设置名称= %% ~nxA


robocopy%文件夹%% 2%名称%/ MOV /LOG+:D:\test\mueve.txt


我真的很喜欢你的解决方案,但我希望我之前找到这篇文章,因为现在我已经转移到GS Richchopy 360,我永远不会再回到使用robocopy了。原因是我每次使用它时都必须去谷歌。这个过程变得耗时。但是GS Richcopy 360让我可以自由地使用易于使用的GUI。无需记住命令参数和许多其他东西。男人很棒,试一试!谢谢!

Hello

I need move all the files the one directory to other and know the path in case of error

I have two simple batch files:

in a batch file with move works :

move %1 %2


but in robocopy :

robocopy %1 %2


doesn't work

any suggestion ?

i need robocopy because the outputs of the logs send me a path with errors and the move isn't

i have two simple batch files

1.

move %1 %2 >> D:\test\log_good.txt 2>>D:\test\log_error.txt   


ITS WORKS but the log don't show the path

this is my simple script and its works ! but i need see in the logs the source and destination path
for the moment the log_good is: 1 files moved

and the log_errors is:

The system cannot find the file specified.
or
The process cannot access the file because it is being used by another process.


I need know in what path occurs the error but i don't know how set the variable %1 (my source) and %2 (my destination) in my logs

2.

In this case:

robocopy %1 %2 /MOV /LOG+:D:\test\mueve.txt


doesn't work my log show me the path but don't move the file and the permissions are correct...

-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows
-------------------------------------------------------------------------------

  Started : Wed Aug 19 12:40:07 2015

   Source : \\diva-disk.mam\tvsa_inter\discos-duros_rz\prueba_mueve_tmp\MARIA_LA_DEL_BARRIO-130-201002232705_DV50_3_prueba_mueve.avi\
     Dest : \\diva-disk.mam\tvsa_inter\discos-duros_rz\prueba_mueve\

    Files : *.*

  Options : *.* /COPY:DAT /MOVE /R:1000000 /W:30

------------------------------------------------------------------------------

2015/08/19 12:40:07 ERROR 267 (0x0000010B) Accessing Source Directory \\diva-disk.mam\tvsa_inter\discos-duros_rz\prueba_mueve_tmp\MARIA_LA_DEL_BARRIO-130-201002232705_DV50_3_prueba_mueve.avi\
The directory name is invalid.

解决方案

For robocopy, both the source and destination must be directories. You are passing the path to a file, and robocopy is correctly telling you that it's not a directory.

To transfer specific files, use robocopy source_dir destination_dir file. For example:

robocopy \\diva-disk.mam\tvsa_inter\discos-duros_rz\prueba_mueve_tmp \\diva-disk.mam\tvsa_inter\discos-duros_rz\prueba_mueve MARIA_LA_DEL_BARRIO-130-201002232705_DV50_3_prueba_mueve.avi /MOV /LOG+:D:\test\mueve.txt



To use that in a batch file, use three parameters:

robocopy %1 %2 %3 /MOV /LOG+:D:\test\mueve.txt



If the application which calls the batch file can't pass the directory and filename separately, then you'll need to do it in the batch file. Google found this[^], which seems to work:

@echo off

For %%A in ("%1") do (
    Set Folder=%%~dpA
    Set Name=%%~nxA
)

robocopy %Folder% %2 %Name% /MOV /LOG+:D:\test\mueve.txt


I really liked your solution but I wish I have found this article earlier because now I have shifted to GS Richchopy 360 and I am never going back to use robocopy. The reason is I had to go to Google everytime whenever I used it. The process becomes time taking. But GS Richcopy 360 gave me the freedom to work with an easy to use GUI. No need to remember the commands the parameters and many other stuff. Man it is great, give it a try! Thanks!


这篇关于使用MOVE或Robocopy使用可变源和目标移动文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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