Sorting the contents of directory

P

Pal

Hello, I need a batch file to do the following: Can some
one please help.

1. Check the contents of C:\INPUT\
2. Check the present month and create a sub folder
C:\INPUT\<MMMYY>\ if it doesn't exist.
3.Check the system date and create a sub folder
C:\INPUT\<MMMYY>\<DDMMM>.
4. Move C:\INPUT\*.* to C:\INPUT\<MMMYY>\<DDMMM>\*.*
 
J

Jerold Schulman

Hello, I need a batch file to do the following: Can some
one please help.

1. Check the contents of C:\INPUT\
2. Check the present month and create a sub folder
C:\INPUT\<MMMYY>\ if it doesn't exist.
3.Check the system date and create a sub folder
C:\INPUT\<MMMYY>\<DDMMM>.
4. Move C:\INPUT\*.* to C:\INPUT\<MMMYY>\<DDMMM>\*.*

Place UnivDate.bat from tip 4835 in the 'Tips & Tricks' at http://www.jsiinc.com
into a folder that is in your PATH, and mmm.bat from tip 6837

@echo off
setlocal
call univdate
if "%yy%" GTR "99" set yy=%yy:~2,2%
set mm=100%mm%%%100
set dd=100%dd%%%100
if %dd% LSS 10 set dd=0%dd%
if %mm% LSS 10 set mm=0%mm%
call mmm month
if not exist c:\input\%month%%yy% md c:\input\%month%%yy%
if not exist c:\input\%month%%yy%\%dd%%month% md
c:\input\%month%%yy%\%dd%%month%
REM the above 2 lines are 1 line
move c:\input\*.* c:\input\%month%%yy%\%dd%%month%




Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
J

Jerold Schulman

Hello, I need a batch file to do the following: Can some
one please help.

1. Check the contents of C:\INPUT\
2. Check the present month and create a sub folder
C:\INPUT\<MMMYY>\ if it doesn't exist.
3.Check the system date and create a sub folder
C:\INPUT\<MMMYY>\<DDMMM>.
4. Move C:\INPUT\*.* to C:\INPUT\<MMMYY>\<DDMMM>\*.*

Oops. Here is a revised post:

Place UnivDate.bat from tip 4835 in the 'Tips & Tricks' at http://www.jsiinc.com
into a folder that is in your PATH, and mmm.bat from tip 6837

@echo off
setlocal
call univdate
set /a yy=10000%yy%10000
if %yy% GTR 99 set yy=%yy:~2,2%
set /a mm=100%mm%%%100
set /a dd=100%dd%%%100
if %dd% LSS 10 set dd=0%dd%
if %mm% LSS 10 set mm=0%mm%
call mmm month
if not exist c:\input\%month%%yy% md c:\input\%month%%yy%
if not exist c:\input\%month%%yy%\%dd%%month% md
c:\input\%month%%yy%\%dd%%month%
REM the above 2 lines are 1 line
move c:\input\*.* c:\input\%month%%yy%\%dd%%month%



Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
P

Pal

Hi Jerold,

There may be some programming error. Because, I get
created a folder MAY-1 instead of MAY04. How to fix this?

Thanks in advance.
-----Original Message-----


Oops. Here is a revised post:

Place UnivDate.bat from tip 4835 in the 'Tips & Tricks'
at http://www.jsiinc.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top