[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.programming

help with batch code to create subfolders inside each folder of a directory and then copy parent folder contents to subfolder

oltre0cean0

10/15/2015 7:59:00 PM

Please, I need some help... I have a folder with around 6000 subfolders with images inside them, each subfolder has a different number of images, and some of them have 0 images also. now i need to create another 2 subfolders inside each subfolder, naming these new subfolders with the names "medium" and "thumbs" and copy inside these subfolders the images that are present in the parent folder. Example: lets say i have a folder named 1000 with 10 images inside it, named 1.jpg, 2.jpg, 3.jpg etc until 10.jpg. I need to create a folder named "medium" and a folder named "thumbs" inside the folder named 1000, and copy the images that are present in the folder 1000 to both new subfolders "1000/medium" and "1000/thumbs". And i need to do this with something like 6000 folders.

i am not a programmer, I am trying to accomplish this and I have been reading the HELP section of the FOR command, execdir command, mkdir, cp command. I also asked for help in other websites and until now I am still lost, and trying to write a code like this:

for /r "c:\folders" %%a in (.) do ( pushd %%a -iname '*.jpg' -execdir \ bash -c 'mkdir -p thumbs medium; mv *.jpg medium; cp -t thumbs medium/*' \; ) popd )
1 Answer

Jacob Sparre Andersen

10/16/2015 7:31:00 AM

0

oltre0cean0 <imofloripa@gmail.com> writes:

> Please, I need some help... I have a folder with around 6000
> subfolders with images inside them, each subfolder has a different
> number of images, and some of them have 0 images also. now i need to
> create another 2 subfolders inside each subfolder, naming these new
> subfolders with the names "medium" and "thumbs" and copy inside these
> subfolders the images that are present in the parent folder. Example:
> lets say i have a folder named 1000 with 10 images inside it, named
> 1.jpg, 2.jpg, 3.jpg etc until 10.jpg. I need to create a folder named
> "medium" and a folder named "thumbs" inside the folder named 1000, and
> copy the images that are present in the folder 1000 to both new
> subfolders "1000/medium" and "1000/thumbs".

In Bash you can do it like this (assuming that all the image files end
in ".jpg"):

for folder in * ; do
for subfolder in medium thumbs ; do
mkdir "${folder}/${subfolder}"
cp -p "${folder}"/*.jpg "${folder}/${subfolder}/"
done
done

Greetings,

Jacob
--
PNG: Pretty Nice Graphics