I would like to copy *.html files from a directory path "C:\abc\xyz\" on my system. I have created a shared folder on my system and I am having the domain admin rights into my user account. I have created a .bat file and commands inside the .bat file is as follows:
pushd \\Target-Hostname\c$\abc\xyz\
xcopy *.html \\Shared-Folder-Path\ /s/e/h/q
popd
However, I get an error "Invalid drive specification". May I know why this error arises? How can alter the command in a .bat file? There are around 100 systems from which I need to copy *.html files (Note: file path on remote systems will remain the same).
Can I copy *.html files by using a VBScript that will execute on a network having domain setup?
UNC paths consist of at least the names of a host and a share on that host, optionally followed by a path below that share:
\\server\share[\sub\folder]
An UNC path \\share\ is invalid, which is what xcopy is telling you.
Also, if you're copying from remote systems to a local folder you don't need an UNC path for the destination in the first place. Simply use the local path:
xcopy \\Target-Hostname\c$\abc\xyz\*.html C:\local\folder /s/e/h/q
Of course you can do the same in VBScript:
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile "\\Target-Hostname\c$\abc\xyz\*.html" "C:\local\folder\"
but just changing the language wouldn't have addressed the misconception in your approach.
Related
I've been stuck on this for awhile and could use some help.
I'm trying to copy a large folder from a mapped network drive (A:) onto my local PC. I also need to exclude a subdirectory on that drive path called "Images". My current code (backup.bat) is below:
cd %HOMEPATH%\Desktop\%mydate%
xcopy "A:\PROGRA~2\QuadTech" 121\ /e /EXCLUDE:"A:\PROGRA~2\QuadTech\INSPEC~1\Images\"
Error I keep getting:
I've tried shortening the path with "dir /x" and I am sure the path name is correct. Also note that I need quotations as there are spaces in the PATH name.
Why am I getting errors when trying to Exclude this directory??
ANSWERED
I now have my Exclude statement point to my desktop where it reads a list of strings in a txt file.
xcopy "A:\PROGRA~2\QuadTech" 121\ /e /EXCLUDE:C:\Users\QuadTech\Desktop\excldelist.txt
Txt file contents:
\Images\
This is happening because the /EXCLUDE option does not specify files to exclude.
It specifies files containing lists of files to exclude.
More info by typing xcopy /?, though I am sure you know that.
(I know, I missed it too in the beginning; sometimes it is just a matter of having a second pair of eyes.)
I am looking for a batch code that will transfer all files inside folders. Then it will transfer them into the location.
D:\Transfered Files\
And it will keep the exact folder/file names.
For example I want everything transfered from
C:\Users\
C:\Program Files\
I have tried this and it works:
xcopy source destination /Y
Just save this in a batch file of course change the directories as you see fit.
Also note that the '/Y' parameter says that if files exist in the destination overwrite them. If you remove it, it will ask you about each file separately.
If you think this isn't good enough you can use robocopy:
robocopy source destination
Again you need to change the source and the destination directories and put the line in batch file.
I have used both and both works 100%. I have a windows 7 home premium 64x.
I would like to creat a batch file that will recognise folders date moidified in a network drive and then copy them to another network drive
while I was searching I found way to do that to files, but I need it for folders
I didn't find a way to do that
Sadly, you didn't say which method you'd found. If that method selects the files using a DIR.../a-d... structure for instance, then omit the - before the d and directories matching the selected pattern rather than files would be processed.
To create a batch file just get notepad++ and save as a .bat, is that what you meant? or did you want a certain type of Batch file, because I didn't think there was another type unless you count Command prompt and Notepad++ different?
Forfiles may be helpful, or robocopy
This will create a mirror backup in the destination folder. If files are deleted in the source then they will also be deleted in the destination.
#echo off
robocopy "\\172.172.172.10\folder" "\\172.172.172.2\destination" /mir
I have a CMD file that contains following command:
START H:\Applications\MyStoreApp\Application.exe
The file is location in the H drive (this is a mapped shared drive) in the folder MyStoreApp.
I want to make my cmd to resolve it's location relatively like this:
START .\Application.exe
I'm getting an error now since it cannot resolve this on a remote host.
Is there anyway to solve this without having to enter the specific location of my file including the mapped network drive?
%~dp0 is the path to the actual script directory (%0 is the script itself).
Considering H:\Applications\MyStore\App\launcher.cmd
#echo "%~dp0Application.exe"
"H:\Applications\MyStoreApp\Application.exe"
Or, for heavy use :
#SET $root=%~dp0
#REM Remove the last backslash
#SET $root=%$root:~0,-1%
#START "App" "%$root%\App.exe" /config "%$root%\App.ini" /log "%$root%\App.log"
Quotes are required in case of spaces in folder name.
For more information about parameter extensions, see SS64.com.
In Windows, how do you copy an entire directory, INCLUDING the parent directory folder?
For instance, let's say we have the directory c:\Folder and want to copy it over to d: .
The only way right now would be:
xcopy /E c:\Folder d:\Folder
Is there a way to do this without specifying the same end directory (Folder)?
I'm told that an application called RoboCopy can do it, however, I believe it's part of a series of server 2003/2008 tools -- I can't speak to its capabilities or whether it will work on your version of Windows. That said, there are a set of tools (basically UNIX commands ported to DOS) located here that will do what you need -- specifically the "cp" command. My apologies for not being able to assist further.