Click here to Skip to main content
15,886,563 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.
Posted
Updated 7-Nov-17 18:53pm
v3

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:
plain
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:
plain
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:
plain
@echo off

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

robocopy %Folder% %2 %Name% /MOV /LOG+:D:\test\mueve.txt
 
Share this answer
 
v3
Comments
EdithMS 25-Aug-15 17:39pm    
thanks for your help Mika and Richard tomorrow i can do a test using this three parameters
and i say if it worked
EdithMS 26-Aug-15 12:47pm    
Hello Mika, Richard isn't work :(

the same error with

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

robocopy don't move the file and view all path like a directory

my log error is:


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

Started : Wed Aug 26 10:53:05 2015

Source : \\diva-disk.mam\youtube_hd\2transcode_tmp\LA_SOMBRA_DEL_PASADO-118-201505154991_.mp4\
Dest : \\diva-disk.mam\youtube_hd\2transcode\

Files : *.*

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

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

2015/08/26 10:53:05 ERROR 267 (0x0000010B) Accessing Source Directory \\diva-disk.mam\youtube_hd\2transcode_tmp\LA_SOMBRA_DEL_PASADO-118-201505154991_.mp4\
The directory name is invalid.
Richard Deeming 26-Aug-15 12:49pm    
You're still only passing two arguments to your batch file. You need to pass the directory and file name separately.

YourBatchFile.bat \\diva-disk.mam\youtube_hd\2transcode_tmp \\diva-disk.mam\youtube_hd\2transcode LA_SOMBRA_DEL_PASADO-118-201505154991_.mp4
EdithMS 26-Aug-15 13:41pm    
in my app (Rhozet) accept this arguments

A Command Line Notifier can be used to trigger external applications on job start, completion, or error. You can use string replacement tokens in your command line execution.

%jobguid% - Unique GUID for this task
%jobname% - Unique name for this task
%source% - Full source path and name
%destinationname% - Destination path and filename (only valid in completion notifications)
%errormessage% - Error message (only valid in error notifications)

Note: The quotation mark is not part of the token

Examples of a command line text:

c:\myprog.exe %source%
c:\myprog.exe "%destinationname%"

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

when i use a simple batch file with this line: MOVE %1 %2

works very good, move the file go to the source and move the files to the destiny but the log don't show me the path in case of error

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:
Hide Copy Code
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

my variables source and destiny its send by my app (Rhozet) its for that im use the parameters %1 for the source and %2 for the destiny



Im try with robocopy because send me the path in the log but don't move the files because the file looks like a folder ..


thanks for your help Richard
Richard Deeming 26-Aug-15 13:47pm    
If the calling application can't separate the path from the filename, then you'll need to find a way to split the path in the batch file. Google found this[^] which seems to do the job:

@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!
 
Share this answer
 
Comments
CHill60 8-Nov-17 4:11am    
So you're no longer using it but you just had to resurrect this 2 year old post to say so!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900