As the title suggests, I would like to copy the data using robocopy in the bat file.
As I want to skip errors and leave logs, I am thinking of using robocopy to copy files.
What is currently being done
Copy a file with a name containing the specified keyword from one folder to another
Not done
Files with spaces in the name cannot be copied
Example: I want to copy a file with a name that contains robo
I wonder if robocopy can't recognize file names including spaces.
I would appreciate it if you could let me know if you know how to copy it in any other way.
Thank you for your cooperation.
"If the name of the file you want to copy has been decided in advance, you can use "" to enclose the name of the file, but
"
What should I do if I want to search for a file in a folder and extract a file that contains the specified name?
You are currently using a for statement.
rem// Specify the folder path from which to copy
set fs_src= ※Any folder path
rem// Specifying Extraction Criteria Characters
set name = robo
for /r%fs_src%%%In(*%name%*.*)drobocopy~
I summarized it briefly, but I wrote the code like the one above.
I was able to copy the data with the name that contains the blank space using the method you advised me to do.
The filename you want to extract: name
robocopy/s"%fs_src%"%fs_bk%"%name%.*"
Filename you want to extract: name
robocopy/s"%fs_src%"%fs_bk%"%name%.*"
Currently trying to output LOG files at the same time as copying, copying only under the same time as copying…
robocopy/s"%fs_src%"%fs_bk%"*%name%*.*"/LOG:%logdir%\%target%_%ToDay%.txt%~pI%fs_bk%%%~nxI
If you continue to type LOG commands as above, only LOG data was created and you could not copy the data.
windows batch-file
Try double-quoting the filename that contains spaces.
"robo.txt", "robo123.ppt"
I think we can handle it with the robotopy argument without using the for statement.
rem// Specify the folder path from which to copy
set fs_src= ※Any folder path
rem // Specify the destination folder path
set fs_dest= ※Any folder path
rem// Specifying Extraction Criteria Characters
set name = robo
robocopy "%fs_src%" "%fs_dest%" "*%name%*.*"
As described in the FOR
Help removes "
that binds variables by adding through
.
After that, you can use "
to correctly handle spaces.
for /r%%I in (*%name%*.*) drobocopy~"%%~I"
© 2024 OneMinuteCode. All rights reserved.