Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replacing a file into multiple folders/subdirectories

Is there a way in command prompt to take one file and copy it into another folder and its subdirectories based on its name?

I have an image named 5.jpg that has been put in a sub-folder that is in every folder in a directory. I want to do a search inside of the folder (with the old image) and its sub-folders and replace all of the results with the new image.

like image 668
abney317 Avatar asked Jul 22 '10 18:07

abney317


People also ask

How do I make multiple subfolders in multiple folders?

Simply hold down the Shift key and click with the right mouse button in the Explorer on the folder where you want to create additional subfolders.

How do I make multiple folders automatically?

Here is how you can do that: Type Notepad in Windows search and click Open. In the Notepad window, click type @ECHO OFF and click Enter. After you have typed down the names of all the folders and subfolders that you want to create, navigate to File in the top-left corner and choose Save as.

How do I copy a file in subdirectories?

To copy a directory with all subdirectories and files, use the cp command.

How do I consolidate files in different folders?

Go to the folder where you had bulk files, press CTRL+A to select all files. Now go and expand the Home ribbon on top and click either Move to or Copy to as per your requirement. Then select Choose location, if you want to move the files to user created folder.


1 Answers

Probably there is one more (simpler) way.

Use the replace command:

replace C:\SourceFile.Txt C:\Some_Root_Folder_Which_Contains_Multiple_SubFolders /s

As the command itself says it just replaces the file, which already existed in sub-directories.

like image 71
Baljeetsingh Avatar answered Oct 14 '22 07:10

Baljeetsingh