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
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.)
So, I was hit with the Cryptowall 3.0 ransomware virus. After decryption I am still left with a large amount of DECRYPT_HELP files in .txt, .html, .png and Windows Shortcut formats.
I need a batch script to recursively find the files containing the name "DECRYPT_HELP" regardless of its' extension and move those files into a directory which I will delete.
I am a Linux guy, so I can't FIND and GREP my way through this. Any assistance would be appreciated.
You can find the files using
dir /s *decrypt_help*
dangerous command follows
del /s *decrypt_help*
will delete all of those files. use with extreme caution
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 have a folder containing many other sub-folders.
I am trying to write a batch file which will copy some of the folders to another place on my hard disk. I am using "xcopy" for this. I am facing following problem:
The folder structure is as shown below-
--FolderB1
---FolderB2
---FolderB22
---File1.txt
---File2.txt
---File3.txt
I have some .txt files inside "FolderB1", along with "FolderB2" and
"FolderB22" I want to copy "FolderB2" and "FolderB22" and skip ".txt"
files contained in "Folder B1"
I tried using /EXCLUDE: param of xcopy command, but it is not able to perform this operation. It does not work if I specify the exclusion as \FolderB1\*.txt or something of this sort.
The number of main folders is not known. It can be anything. Also, there is no fix pattern for names of ".txt" files. Have checked this question too, but did not help.
Alternate method or other pointers for the same would be a great help. Thanks in advance.
What you could try to do is to hide the files you don't want to copy, then execute the xcopy, and then unhide the files again.
Look at my answer of question Windows batch script to delete everything in a folder except one. That question was related do deleting files (excluding some files), but you can probably use the same trick for xcopy-ing files.
I need to copy a particular file from one location to another., Is it possible to use robocopy to do same.
Whilst Robocopy can be persuaded to copy a single file it is much simpler to use copy or xcopy.
Yes, either wrap it in an an exec or use the Robocopy that is wrapped as part of the msbuild extension pack see:http://www.msbuildextensionpack.com/help/4.0.3.0/index.html
You want to use the MSBuild.ExtensionPack.FileSystem.RoboCopy task.
Makes copying much quicker.
I was trying to figure this problem out. I finally found my own solution and maybe it will help.
I noticed that the syntax used to select the entire directory could be used to select a single file.
ROBOCOPY "*" "Directory source" "Directory Output unc path or non"
The above code will copy everything from the directory source folder to the directory output path.
Let's say you only wanted to copy 1 file from the directory source named "test.txt"
In order to do that use the following code:
ROBOCOPY "*test.txt" "Directory source" "Directory Output unc path or non"
Thats about it. It works really well and will only copy the file name you want.
Alternatively you can use
ROBOCOPY "*.txt" "Directory source" "Directory Output unc path or non"
to copy out all text documents from the directory source.
Similarly this will also work with any .ext
.zip .exe .txt .pdf etc..
I signed up to answer this question with a better method. Let me know if I succeeded.