3

I am looking for a .bat file that can look inside multiple folders that contain sub-folders that are named the same and move their contents to a specified folder.

Folder Structure:
Main_folder

  1. MainTextures_folder
  2. Props_folder
    --model1_subfolder
    ------Textures_subfolder
    ----------image files
    --model2_subfolder
    -------Textures_subfolder
    ----------image files
    --model3_subfolder
    -------Textures_subfolder
    ----------image files
    --model4_subfolder
    -------Textures_subfolder
    ----------image files

I need all image files moved from their Textures_subfolder to the MainTextures_folder.

Thanks for any help.

Dany Bee
  • 552
  • 3
  • 12
user2493464
  • 35
  • 1
  • 6
  • http://stackoverflow.com/questions/6258908/move-all-files-in-a-folder-and-all-its-subfolders-into-one-big-folder-windows – krish kim Jun 17 '13 at 13:30
  • the problem i have with this solution (which is a good one) is that there is a corresponding .meta file with each file within the entire folder structure. i do need to move the .meta files that correspond to the image files, but not the model files. therefore, if i add .meta to the search it will find files that i do not want to move (i.e. the .meta files for the models) – user2493464 Jun 17 '13 at 15:19

2 Answers2

4

This expects model* folders under the props folder, and that each model* folder has a textures folder. The MainTextures folder is in the Main_folder.

It's untested and should move all files from each textures folder into the MainTextures folder.

@echo off
pushd "Main_folder\Props"
for /f "delims=" %%a in ('dir model* /b /ad') do (
move /-y "%%a\textures\*.*" "..\MainTextures"
)
popd
foxidrive
  • 40,353
  • 10
  • 53
  • 68
  • that worked great!!! now...you have "('dir model* /b /ad')", what needs to be written if each model folder has a unique name (model1 = truck_model, model2 = plane_model, etc)? – user2493464 Jun 17 '13 at 15:29
  • If each folder under Props is a model folder then remove `model*` altogether. – foxidrive Jun 17 '13 at 15:30
  • You're welcome. You can accept the answer, and others in future will know that it's worth trying. – foxidrive Jun 17 '13 at 23:17
2
for /r "Props_folder" %%x in (*.jpg *.png *.bmp *.whatever) move "%%~fx" "MainTextures_folder"

This code will overwrite all existing files.

captcha
  • 3,756
  • 12
  • 21
  • this is not working for me. i copied the code and pasted it into a txt document and changed it to a bat file. put the file inside the main folder and ran it. nothing happened. – user2493464 Jun 17 '13 at 14:56