How to copy one folder into multiple folders in windows - windows

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

Related

Copying 1 file into multiple subfolders

I am a novice. I am trying to copy 1 file into multiple subfolders within windows file explorer. I have successfully copied 1 file into multiple folders within a specified drive using the template below using the CMD prompt.
for /D %a in ("path-to-folder*.*") do xcopy /y /d "Path-to-file\file.FileExt" "%a"
This successfully copies one file to all folders within a specified folder.
Unfortunately I need to copy 1 file into multiple subfolders within a file. I will try to explain as best I can below:
I need an Excel file to copy to all Facility Subfolders within a Facility Folder under Folder1.
File.xls --> Folder 1 --> Facility Folder --> Facility Subfolder
Does that make sense? I need to do this frequently and copy and pasting the excel file to all facility subfolders is time consuming.
Thank you for any assistance!
D

Move directories with wildcards into another directory with robocopy or move in cmd

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

Batch file to copy and rename files

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

.bat file for copy-pasting folder in Windows XP

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.

Batch to move files in a folder to another folder?

I want to create a batch file that moves all the files in this directory to its father directory. Like for example if I have a directory " Something " that contains files :
...New Folder/Something
And I want to move the files in " Something " to New folder.
Is there such a command?
Thanks a bunch :)
Presuming you're talking about Windows batch files, move *.* ..\ should do the trick.
Edit: For example, if you opened cmd, you could input:
cd C:\New Folder\Something
move *.* ..\
which would move all files in C:\New Folder\Something into its 'father' directory.
It is possible only if you don't have subdirectories, because move doesn't walk the subdirectories.
You can use xcopy with /E, however it will not delete the copied files and directories. Then you should use del ., but to delete the subdirectories you should call rd for each one, and that is not possible in batch files.

Resources