How to robocopy directories with spaces AND special characters in the name - robocopy

Hey there I'm running into an issue when trying to robocopy several thousand files to a destination folder that contains spaces and special characters.
Code:
robocopy "SOURCE" "\\arc\GLUONPREP\Market Centers\~1 FOR MC TEAM\Apparel Logos " *-1c.pdf /MT:64 /XX /R:1 /W:0 /S
Result:
Started : Thursday, July 29, 2021 12:04:21 PM
Source - [omitted for privacy]
Dest - C:\Users\joshh\Centers\~1\
Files : FOR
MC
Options : /DCOPY:DA /COPY:DAT /R:1000000 /W:30
------------------------------------------------------------------------------
ERROR : Invalid Parameter #5 : "TEAM\Apparel"
I was reading that in order to handle spaces in directories, some have added a space right before the ending double quote. But I'm seeing that it might be a combination of spaces and special characters.
I've tried reading the documentation but I couldn't find anything and haven't found another question similar that has been answered or where the solution worked.
If you have a link to another article I could check out that would be great or a solution that would be extremely helpful!
Thank you!

try xcopy
xcopy /S /I /E "source path" "destination path"
for more usage of xcopy visit

Related

Windows script to merge all .html files in a directory and its subdirectories into a single .html file?

I have a Results directory, which has many subdirectories each containing a HTML file with a specific naming format, _ExeReport.html.
I want to write a Windows script which merges each of those files into one file.
For now, I tried running two commands :
dir /S *_ExeReport.html
This is listing all the files (with some extra information), and:
copy /b *.html final.html
This is merging all the files in current directory into one file.
But, I am not able to write a script which can combine and do everything I need.
Can someone help me with this? I am newbie to scripting languages.
Thanks to #T3RR0R for sharing the link. My final command :
FOR /F "tokens=*" %G IN ('dir /b /s *_ExeReport.html') DO TYPE "%G" >> MergedOutput.html

CMD dir List video files - Not Found error

I crafted some command line code (function? I don't know the technical term, my apologies) that is meant to look in a network folder (and all it's subfolders) and only list the file path for those files that are a particular type. I tried to test it on a folder with less information in it first, however I got the error File Not Found. This confused me because I looked in the folder--there were definitely .VOB and .mp4 files in the specified folder.
When I run the code included below, I don't get the error, BUT I'm getting a bunch of files I don't want (.pdf .xml .jpeg--etc.) I think because they're system files such as the .jpeg files for the .avi thumbnails.
dir "\\nas-rb4b\projectx2" /s /b *.avi *.mov *.mp4 *.wmv *.mpg *.lnk *.ldb *.rar *.mpeg *.m4v *.vob *.zip>Projx2RERUN.txt
Can anyone help me understand why I got the File Not Found error when I tried to run the exact same code but with a different more specific folder?
I also don't know how to modify the code/function to exclude files that are not the listed file types and are not system folders. Any help is, as always, much appreciated!
Read the newest dir command reference in Windows Commands:
Syntax:
dir [<Drive>:][<Path>][<FileName>] [...] [/p] [/q] [/w] [/d] [/a[[:]<Attributes>]][/o[[:]<SortOrder>]] [/t[[:]<TimeField>]] [/s] [/b] [/l] [/n] [/x] [/c] [/4]
Remarks:
To use multiple FileName parameters, separate each file name with a
space, comma, or semicolon.
The command in question dir "\\nas-rb4b\projectx2" /s /b *.avi *.mov *.mp4
(truncated) says and performs the following:
dir "\\nas-rb4b\projectx2" /s /b, (i.e. all files in "\\nas-rb4b\projectx2"), then
dir /s /b *.avi (i.e. all .avi files in the current directory), then
dir /s /b *.mov (i.e. all .mov files in the current directory), then
dir /s /b *.mp4 (i.e. all .mp4 files in the current directory), …
Solution (read pushd and popd reference as well):
pushd "\\nas-rb4b\projectx2"
dir /s /b *.avi *.mov *.mp4 *.wmv *.mpg *.lnk *.ldb *.rar *.mpeg *.m4v *.vob *.zip>Projx2RERUN.txt
popd
Following some advice from Ken White along with a combination of the answers given here, here, and information from here I made the expression below which eventually worked for me.
dir /b /s \\nas-rb4b\projectx2\*.avi \\nas-rb4b\projectx2\*.mov \\nas-rb4b\projectx2\*.mp4 \\nas-rb4b\projectx2\*.wmv \\nas-rb4b\projectx2\*.mpg \\nas-rb4b\projectx2\*.rar \\nas-rb4b\projectx2\*.mpeg \\nas-rb4b\projectx2\*.m4v \\nas-rb4b\projectx2\*.vob \\nas-rb4b\projectx2\*.zip
It is not pretty but it allowed me to search for multiple file types using only one expression and have their paths all sent to one txt file rather than searching each file extension individually.
So far it is working as intended.

Best way to compare some text files

Here is the simplified version of the situation I'm dealing with:
Folder Files1 containing a.txt, b.txt, c.txt
Folder Files2 containing a.txt, b.txt, c.txt
I want to find the best way to compare these files. All I need to know is which files are different. For example I need to know a.txt is different from a.txt in Files2 folder (I don't need to know what is different inside them).
Right now I load both in Notepad++ and use the compare function, but this is a pain.
I tried fc, but I'm getting cryptic output.
You could use Robocopy for that
robocopy c:\Temp\different\folder1 c:\temp\different\folder2 /e /l /ns /njs /njh /ndl /fp /log:c:\temp\whatIsDifferent.txt
Newer c:\Temp\different\folder1\b.txt
New File c:\Temp\different\folder1\d.txt
the key parameter is /L which allows you to "compare" instead of actually copying.
From Robocopy /? help
::
:: Logging Options :
::
/L :: List only - don't copy, timestamp or delete any files.
Do a dry-run (/l) with robocopy:
robocopy C:\files1 C:\files2 /njh /njs /ndl /l
/l Specifies that files are to be listed only (and not copied, deleted, or time stamped).
Rsync can be used to do this.
rsync -rvnc —delete delme/ delme2/
This will show you which files differ in the 2 directories.
See http://www.techrepublic.com/blog/linux-and-open-source/how-to-compare-the-content-of-two-or-more-directories-automatically/ for me details.

Robocopy command line - file with spaces

I am trying to run the following command:
robocopy.exe \\eisdevl.nas.gatech.edu\coldfusion\devl\cfapps\cfeis\mybeap \\eisdevl.nas.gatech.edu\coldfusion\test\cfapps\cfeis\mybeap "ADMIN_HEADER.CFM" "new folder\NEW TEXT 3.TXT" /mir /log:\\eisdevl.nas.gatech.edu\coldfusion\devl\cfapps\cfei\mysync2\logs\rc_09032013_lrobinson33_1.txt /NDL /r:2 /w:2
From this I get:
Started : Wed Sep 04 09:32:22 2013
Source - \eisdevl.nas.gatech.edu\coldfusion\devl\cfapps\cfeis\mybeap\
Dest - \eisdevl.nas.gatech.edu\coldfusion\test\cfapps\cfeis\mybeap\
Files : ADMIN_HEADER.CFM
Options : /COPY:DAT /R:1000000 /W:30
ERROR : Invalid Parameter #4 : "new folder\NEW TEXT 3.TXT"
Can anyone give me the correct syntax for dealing with spaces in the folder AND file name?
The ending backslash \ on the directory isn't allowed. Just specify the full path without the ending \ on it. You can use the "pathnames" in quotes just fine then.
Enclose everything in double quotes that will have spaces or other poison characters. They can also be used with short names safely.
robocopy.exe "<fromdir>" "<todir>" "file.cfm" "new file 3.cfm" /mir /log:"#path#\cfeis\mysync2\logs\rc_090313.txt" /NDL /r:2 /w:2
c:\Program" "Files
Would be the answer that worked for me.
Thanks New Guy. I had this:
robocopy "%source%\Core" "%destination%\Core" Start.br Client.br Menu.br Check File Versions.br
trying to get the four files:
Start.br
Client.br
Menu.br
Check File Versions.br
But it just wouldn't work until I tried your trick: (notice the new double quotes)
robocopy "%source%\Core" "%destination%\Core" Start.br Client.br Menu.br Check" "File" "Versions.br
Now it works great. Don't think I ever would have thought to try that befoe.

Making batch file for copying

Can anyone advise me please im using Windows XP Pro on C drive and need to be able to copy a file from one drive to another. This case original will have to be renamed and old file must be put on another Partiton which is on a Server Example K drive.
Alternately There is another option using Windows 7 on a another computer instead of Windows XP Pro. So any answers appreciated.
A quick look on my old DOS book that I saved just in case that I have to make batch files says COPY is the right command.
Syntax:
COPY DRIVE:FILENAME DRIVE:FILENAME
COPY THISFILE THATFILE
If your permissions are setup to allow copying, you can use "UNC" paths to copy files across servers and drives.
Like Noah said, check out ROBOCOPY or the slightly less featured XCOPY.
Enter copy /? or xcopy /? to find out the available options - if you append >file.txt you'll get them in a text file.
XCOPY Command:
xcopy c:\sourceDirectory\*.* d:\destinationDirectory\*.* /D /E /C /R /Y
ROBOCOPY Command:
robocopy c:\sourceDirectory\*.* d:\destinationDirectory\*.* /R:5 /W:3 /Z /XX /TEE
Either of these should work for you
Have you looked into robocopy?