I am trying to copy files from folder1 to folder2 but exclude few files. lets say
Source dir: D:\test1
Dest dir: D:\test2
Source dir has files: hello1.txt, hello2.txt, hello3.pdf.....(and so on with different extension)
My batch cmd: Xcopy /Y /exclude:D:\test1\Excludefiles.txt D:\test1 D:\test2
I have added list of files in Excludefiles.txt that I dont want to copy.
The issue is everything works fine except Excludefiles.txt gets copied in dest folder too which I dont want. How can I exclude Excludefiles.txt getting copied?
Related
This is the issue. I have a folder named Covers which is in another folder named Folder A. I have to copy the Covers folder from Folder A to all the sub-folders of another folder named Folder B. There are hundreds of sub-folders in Folder B. How can I do it through command line in windows or even power-shell.
Here is the folder structure:
Folder A
Folder B
Covers
Sub-Folder 1
Sub-Folder 2
Sub-Folder 3
Sub-Folder 4
The path of the FolderA is D:\AJ\Desktop\FolderA and the path of FolderB is D:\AJ\Desktop\FolderB.
I am trying to copy Covers folder from FolderA to all the sub-folders of FolderB.
This should do it. Use for /? to see the help for the command. /d means wildcards match directories, so it loops through the folders under FolderB and copies the files. xcopy /? will show that /sei will assume the destiniation is a directory and copy subdirectories including empty ones, to make sure everything under Covers gets copied. Use the cd command to start in the initial directory containing the folders:
cd /d d:\aj\desktop
for /d %i in (FolderB\*) do #xcopy "FolderA\Covers" "%i\Covers" /sei
I have a question, I have the following paths:
C:\Vendita\folder1\files and subfolders
C:\Vendita\folder3\files and subfolders
C:\Vendita\folder3\files and subfolders
I want to delete (using win shell commands), for each subfolder (C:\Vendita\folder1,C:\Vendita\folder2,C:\Vendita\folder2...) all files and subfolders, but keeping folder1, folder2 ecc...
I try this:
for %D in (C:\Vendita\) do del *.* /s /q
but it deletes all files and keeps all subfolders.
Can you explain me what is wrong?
Thank you
Why don't you use rmdir? Your command only removes files with a certain filename.
I read Windows batch command to move all folders in a directory with exceptions but this did not work with wildcards. I want to move all folders (!), not files, inside a folder into 2010.
I have 2010-01, 2010-02, 2010-03, ... but also 2011-01, ...
How can I move (!) all folders including files inside 2010. For files this works perfectly with
move *2010* 2010
where the second 2010 is the destination folder.
Probably robocopy is the right tool for you. You can use the following command to move all directories and files from the directory source_dir into target_dir, preserving the directory structure:
c:\robocopy source_dir target_dir /S /MOVE
I need a batch file that:
Copies all items (directories and subdirectories) from folder a to folder b
If I overwrite a file name/folder in folder a then it will correctly rename file/folder in folder b
I have accomplished the first task:
#echo off
xcopy "D:\...\abc\*.*" "D:\...\def" /E
pause
Above copies all the content in the folder to by destination folder i.e.
Folder a:
-folder1, folder2
-fileA, fileB
Is correctly present in folder b. However, if I rename a file in folder a and run the script:
rename folder1 -> folder0
Then this is how file structure looks:
Folder b:
-folder1, folder2, folder0
-fileA, fileB
I want folder1 to be renamed to folder0, how do I do this?
I could overwrite everything (not sure how with xcopy) but is there another solution to this?
I've looked at the various flags, but can't find what I'm after.
I think what you want it robocopy
You can mirror your folderA to folderB on execution of this batch file:
robocopy "D:\...\abc" "D:\...\def" /MIR /FFT /Z /XA:H /W:5
A great tutorial can be found here, explaining the various params
I need to copy-paste a folder (files + subfolders) into a BackUpfolder. I also need to append the time into the BackUp folder name. xcopy command is letting me copy only files. Your help would be appreciated.
Source Folder = "C:\Documents and Settings.....\Project" (has many files + subfolders)
Target Folder = "C:\Backup-Date/time of backup" Eg Bacup:May 16 2011 12:30 AM
I plan to run this bat file through Scheduler. Thanks!
XCOPY
Copy files and/or directory trees to another folder. XCOPY is similar to the COPY command except that it has additional switches to specify both the source and destination in detail.
XCOPY is particularly useful when copying files from CDROM to a hard drive, as it will automatically remove the read-only attribute.
Syntax
XCOPY source [destination] [options]
/S Copy folders and subfolders
/E Copy folders and subfolders, including Empty folders.
May be used to modify /T.
/H Copy hidden and system files and folders (default=N)
Key
source : Pathname for the file(s) to be copied.
destination : Pathname for the new file(s).
There are several options you can look at :http://ss64.com/nt/xcopy.html
Soruce: http://ss64.com/nt/xcopy.html
I think reading the documentation of xcopy would go a long way.