Copying 1 file into multiple subfolders - windows

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

Related

How to batch copy a list of folders and its file contents from a text file into a new folder in windows

I have a folder with approximately 7000 subfolders. I am interested in copying 1500 of those subfolders and their file contents into a new folder.
The closest I have got is copying the subfolders file contents into a new Target folder. However, the file contents are not copied over within their resepective subfolder making the batch copy useless to me.
Here is what I have tried.
CD E:\Source_Folder
FOR /F "delims=" %%N in (List.txt) do COPY "%%N" "Target_Folder"
I have tried XCOPY, ROBOCOPY, as well and all give me the same output of individual files in my target folder. I am looking for the subfolders with their contents to be copied into my new target folder.
Any help would be much appreciated. Thanks!
Just a try: rsync in linux does have the option to take the file-list to be synced from a file. Maybe robocopy (which is the windows-pendant) has the same capability, then you need one robocopy x y z only.
-edit: robocopy can'r read from a file, but if you search for 'robocopy reading from list' you get a lot of short scripts.

Batch OCR files in subfolders and save new files with new name

I have the following code, which OCR's all PDF files in a specific folder (d:\extracttmp2), but it does not rename the files as I would like, or put the new files in the right place.
Currently, all files are within subfolders of 'extracttmp2'.
The OCR runs correctly, but I would like the OCR'ed files to be renamed to: <parent folder path>-<filename>_ocred.pdf. Naming them in such a manner will produce no file overwrites.
Currently, the code OCR's the files, but it saves the new files to the folder above the folder they are located in. It also saves the filenames as "JAN_ocred.pdf", for example, for a file named "JAN.pdf". The result of saving up one folder leads to some file overwrites, which is unwanted.
Also, it doesn't matter if the OCR'ed files remain in the folder where the un-OCR'ed files are located, or if they're saved up one folder. The desired renaming will eliminate any overwrites.
The software I'm using is PDF24. https://creator.pdf24.org/manual/10/#command-line. However, I think that my problem is not with the OCR software, but my syntax in the batch script.
Can anyone tell me what I am doing wrong?
For /R d:\extracttmp2\ %%G in (*.pdf) do "C:\Program Files\PDF24\pdf24-Ocr.exe" -outputFile "%%~nG_ocred.pdf" -language eng -dpi 300 -skipFilesWithText "%%G"
Is this what you mean? i.e. files will be saved in the same location as before, but each name will be prefixed with their parent directories' name, followed by a hyphen/dash.
#For /R "D:\extracttmp2" %%G In (*.pdf) Do #For %%H In ("%%~dpG.") Do #"%ProgramFiles%\PDF24\pdf24-Ocr.exe" -outputFile "%%~nxH-%%~nG_ocred%%~xG" -language eng -dpi 300 -skipFilesWithText "%%G"
Just a quick clarification: D:\extracttmp2\directory1\JAN.pdf would be saved in the working directory with the name directory1-JAN_ocred.pdf, and D:\extracttmp2\directory2\subdirectory3\SOMENAME.pdf, as subdirectory3-SOMENAME_ocred.pdf
If you want to save the files somewhere else, either change the working directory, or prepend it to %%~nxH-%%~nG_ocred%%~xG

Batch file to create folders and subfolders and copy files into them

I need to copy any pdf files with the word "approved" in the file name from here:
C:\Projects\Project_1\
C:\Projects\Project_2\
To here:
C:\Attachments\Project_1\Documents\
C:\Attachments\Project_2\Documents\
The batch file needs to create the project folder as well as 2 subfolders, "Documents" and "Images" and put the corresponding pdf files in the "Documents" folder.
I created a simple batch file using xcopy but I cannot figure out a way to put the pdfs into a subfolder.
xcopy "C:\Projects\Project_1*approved*" "C:\Attachments\" /s /d /y

Auto save file from one local disk to another

I have two local drives and one .xlsx file that dropped every day on local drive1.
Is that possible to auto save that file on local drive2 after it appeared on the first?
Create a text file with following content and save it as Batch File(e.g.: copier.bat):
xcopy "e:\source_folder\source.xls" "f:\destination_folder" /e /i /h
Here,
xcopy is a basic copy command
So, when you double click copier.bat your excel file will be copied.
It can be used to copy multiple Files and Folders as well.

.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.

Resources