1000 folders, move certain file types

October 16, 2010 at 03:13:03
Specs: Windows 7 HPrem, 2Ghz/3Gb
I have around 1,000 folders that are in one main folder, which I've called UK.

In each of the these 1,000 sub-folders in UK, there are about 14 files, 10 which are .htm and the other 4 are image files, so .gif and .jpg.

What I need to be able to do is; for each sub-folder e.g. manchester, london, birmingham etc.. is create a sub folder within that town directory (mancheser) called images and then move these 4 image filetypes into this image folder.

So the end result will look like


C:\UK\Manchester\
all .htm files

C:\UK\Manchester\Images\
all .jpg and .gif files

###############

C:\UK\london\
all .htm files

C:\UK\london\Images\
all .jpg and .gif files

################

I hope I have explained this ok?

Thanks in advance to anyone that can help with this.

Super Zee


See More: 1000 folders, move certain file types

Report •


#1
October 16, 2010 at 03:44:54
NOT TESTED because I can't be bothered to create a similar structure. I highly recommend you run it with the ECHO and watch what it does, so it doesn't make a mess.

============================================
@echo off & setLocal EnableDELAYedeXpansion

pushd C:\UK

for /f "tokens=* delims= " %%a in ('dir/b/ad') do (
pushd %%a
md images
for /f "tokens=* delims= " %%i in ('dir/b *.gif *.jpg') do (
echo move %%i images
)
popd
)


=====================================
Life is too important to be taken seriously.

M2


Report •

#2
October 16, 2010 at 05:03:42
I've just tried this and it creates the directory which is great, but it doesn't do the second stage of the bat file which is move the .jpg and .gif files to images directory?

And it also doesn't come back with any errors, strange??? :?


Report •

#3
October 16, 2010 at 05:09:06


Report •

Related Solutions

#4
October 16, 2010 at 05:10:35
image of the command prompt here;

http://www.just4hosting.co.uk/move_...


Report •

#5
October 16, 2010 at 05:16:30
To activate, remove the ECHO from this line:

echo move %%i images


=====================================
Life is too important to be taken seriously.

M2


Report •

#6
October 16, 2010 at 05:29:01
sorry my bad

Report •

#7
October 16, 2010 at 05:34:31
works like a charm

Thanks M2


Report •


Ask Question