Moving even numbered filenames to new folder

September 25, 2009 at 20:06:18
Specs: Windows XP
I have a folder with thousands of images and I need to separate the odd from the even numbered ones. The filenames are something
like 0001248.tif and they are not in consecutive order. Was wondering if anyone had a batch file to move the even ones to a new folder. Any help would be greatly appreciated. Thanks!!!

See More: Moving even numbered filenames to new folder

Report •


#1
September 25, 2009 at 20:46:50
Perhaps this may do it:

pushd "c:\your\image\folder"
for /l %%a in (0 2 8) do (
    for /f "delims=" %%b in ('2^>nul dir /b "*%%a.tif"') do (
        move "%%~fb" "c:\your\new folder"
    )
)
popd

It seems more code than needed but move seems to be sloppy on wildcards....


Batch Variable how to


Report •

#2
September 25, 2009 at 21:05:02
Thank you soooo much! That works like a charm.
I really appreciate the time & effort you and all the others
put in to help out others.
Thanks again!

Report •

#3
September 26, 2009 at 01:10:08
Hi Judago,

I see no way to do it with less code. I think you nailed it down.


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
September 26, 2009 at 01:23:36
well OK maybe a little less

--------------------------------
@echo off & setLocal EnableDELAYedExpansion

pushd c:\thetifs
for /f "tokens=* delims= " %%a in ('2^>nul dir/b *.tif') do (
set /a E=%%~Na%%2 & if !E! equ 0 move %%a C:\eventifs
)


=====================================
Helping others achieve escape felicity

M2


Report •

#5
September 26, 2009 at 01:36:56
Yeah, it kinda just felt long cause I was getting weird results with "dir /b *0.tif *2.tif *4.tif *.6.tif *8.tif", not sure why but *3.tif was also being returned.

That said, I find that any method that avoids delayed expansion on text files or file names is a good thing of the disappearing !'s.


Batch Variable how to


Report •


Ask Question