Clean up code in a bat file

March 26, 2009 at 03:27:29
Specs: Windows XP
Hi all

After reading posts here I found a way to move several files from and to another directory. How ever.... It seems that the code will get to long and i wounder if there is a more easy way to this without so many lines.

dir /b *1_*.pdf* > Move_List.txt
for /f %%i in (Move_List.txt) do move %%i C:\Tc001

dir /b *2_*.pdf* > Move_List2.txt
for /f %%i in (Move_List2.txt) do move %%i C:\Tc002

dir /b *61_*.pdf* > Move_List.txt
for /f %%i in (Move_List.txt) do move %%i C:\Tc002G

dir /b *3_ *pdf* > Move_List2.txt
for /f %%i in (Move_List2.txt) do move %%i C:\Tc003

dir /b *<b></b>pdf* > Move_List.txt
for /f %%i in (Move_List.txt) do move %%i C:\Tc003

dir /b *61c_*.pdf* > Move_List2.txt
for /f %%i in (Move_List2.txt) do move %%i C:\Tc003B

dir /b *61_*.pdf* > Move_List.txt
for /f %%i in (Move_List.txt) do move %%i C:\Tc003C

dir /b *61c_*.pdf* > Move_List2.txt
for /f %%i in (Move_List2.txt) do move %%i C:\Tc003D

There are over 100 different dir. to match :-)

I really hope that someone can help me...


See More: Clean up code in a bat file

Report •


#1
March 26, 2009 at 03:51:03
[1] I'm leary of the pdf* , but maybe you have multiple extensions, whci ought to keep things pretty confused.

[2] You can eliminat 1 line per section; skip the creation of a file, llike this:

for /f "tokens=* delims= " %%a in ('dir/b bla*.pdf') do (
move %%a d:\dest
)


Not obvious how you generalize the dest v filename.


=====================================
If at first you don't succeed, you're about average.

M2


Report •

#2
March 26, 2009 at 04:49:59
Hi

Thanx for the "clean up" it worked like a charm !


Report •

Related Solutions


Ask Question