Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming > #5920

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

From Jacob Sparre Andersen <sparre@nbi.dk>
Newsgroups comp.programming
Subject Re: help with batch code to create subfolders inside each folder of a directory and then copy parent folder contents to subfolder
Date 2015-10-16 09:31 +0200
Organization JSA Research & Innovation
Message-ID <8737xbtglk.fsf@adaheads.sparre-andersen.dk> (permalink)
References <877bca17-7c4c-4538-9aa5-d6fc0b2201ad@googlegroups.com>

Show all headers | View raw


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

Back to comp.programming | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

help with batch code to create subfolders inside each folder of a directory and then copy parent folder contents to subfolder oltre0cean0 <imofloripa@gmail.com> - 2015-10-15 12:59 -0700
  Re: help with batch code to create subfolders inside each folder of a directory and then copy parent folder contents to subfolder Jacob Sparre Andersen <sparre@nbi.dk> - 2015-10-16 09:31 +0200

csiph-web