Computing.Net > Forums > Programming > Clean up code in a bat file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Clean up code in a bat file

Reply to Message Icon

Name: newbee
Date: March 26, 2009 at 03:27:29 Pacific
OS: Windows XP
Subcategory: Batch
Comment:

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...



Sponsored Link
Ads by Google

Response Number 1
Name: Mechanix2Go
Date: March 26, 2009 at 03:51:03 Pacific
Reply:

[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


0

Response Number 2
Name: newbee
Date: March 26, 2009 at 04:49:59 Pacific
Reply:

Hi

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Problem with counting fil... Txt renamer from content?



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Clean up code in a bat file

dos .bat file coding help www.computing.net/answers/programming/dos-bat-file-coding-help/16765.html

Backgroud a bat file in window XP www.computing.net/answers/programming/backgroud-a-bat-file-in-window-xp/11963.html

Keyboard commands in a Bat file www.computing.net/answers/programming/keyboard-commands-in-a-bat-file/9360.html