A couple of days ago, I ran into a problem: after processing a VERY large number of photos with some software, it put all the files in one folder.
Although the program was initially set to overwrite the original files with the processed versions, this feature worked incorrectly and did not replace all the files.
There were not many options left: either find other software for the same task or find a way to move the files into their respective folders.
For a visual example, see:
There is one folder (/photo-start/) containing more than 100 folders (/photo-start/name1/name2/2010/). After processing, all the photos/files were placed in the folder /finish-photo/
Manually moving thousands of files into their respective folders is hellish work, so I had to find an automatic solution: move all the data from the folder with the processed files back to its original location.
Twitter suggested a solution and gave me hope that the problem could be solved:
promoTools instead of manual workForty-four generators, converters, and checkers—all running in your browser.View allit would have been easier to put them in their respective folders after processing. Now, I guess the only option is to write a bash script using find.
— Ivan (@ivanxp) March 13, 2015
Since I'm not good with bash, I decided to look for a script or some software that had already been written. But I couldn't find anything useful: nothing worked as needed, and not all files were replaced (possibly because of Russian names).
After a few minutes of searching, I found another simple way to replace files while preserving the folder hierarchy:
replace C:\Users\USER\Documents\uploads\* C:\Users\USER\Documents\uploads2\ /s
1. Enter the path from which to move the files
2. Specify the folder where they should be replaced/overwritten
3. Add the /s switch at the end. It replaces files while preserving the folder structure—in all subfolders of the target folder, along with all their contents;
To run the command, open the CMD command prompt. You can do this by pressing WIN + R and typing the following into the search box: CMD
It's a simple and straightforward solution that may be useful to someone else.
By the way, you can use this command to replace any config or settings file, htaccess, etc. everywhere. To do this, run the command with the FILE NAME
replace C:\Users\USER\Documents\uploads\config.php C:\Users\USER\Documents\uploads2\ /s
In this case, the file config.php will be replaced in all folders and subfolders. Sometimes this is a very convenient and fast way to do it!
Comments (2)
The discussion was moved with the post: the dates and authors are the same as before. New comments aren't accepted on archived posts.
seoonly.ru
Шикарно. Спасибо, помогло
Михаил
Большое спасибо. Очень помогло. Только пришлось сначала создать путь к папкам без пробелов (у меня пробелами было — не получалось), и еще пришлось убрать слеш в конце пути ко второй папке, то есть, не «C:UsersUSERDocumentsuploads2», как в вашем примере, а «C:UsersUSERDocumentsuploads2».