Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #5919 > unrolled thread
| Started by | oltre0cean0 <imofloripa@gmail.com> |
|---|---|
| First post | 2015-10-15 12:59 -0700 |
| Last post | 2015-10-16 09:31 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.programming
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
| From | oltre0cean0 <imofloripa@gmail.com> |
|---|---|
| Date | 2015-10-15 12:59 -0700 |
| Subject | help with batch code to create subfolders inside each folder of a directory and then copy parent folder contents to subfolder |
| Message-ID | <877bca17-7c4c-4538-9aa5-d6fc0b2201ad@googlegroups.com> |
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 )
[toc] | [next] | [standalone]
| From | Jacob Sparre Andersen <sparre@nbi.dk> |
|---|---|
| Date | 2015-10-16 09:31 +0200 |
| Message-ID | <8737xbtglk.fsf@adaheads.sparre-andersen.dk> |
| In reply to | #5919 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.programming
csiph-web