Hallo to all,

I'm glad to find this great forum here!

My career is system admin in a small company.
We are two, one for the hardware and one for the software.
My partner is the programmer and i'm the network and hardware guy.
He is in a hospital right now with a broken leg and two broken arms after a car accident.

Three days ago my boss came into my office and made a request about a new method of sorting files.
I was using batch-files for years, but now he want to have some changes.

What he want to have is:
If a file is in "\direction\folder", move it to "\direction2\year\month\day"
That all should be in an endles loop.

My first try for testing was:

 Code:
Break on

$Monate = "JAN FEB MAR APR MAY JUN JUL AUG SEP OCT NOV DEC"			; Monate

$File = "*.*"
$FileDate = GetFileTime ($File)	
$FileYear = SubStr($FileDate,1,4)
$FileMonth = SubStr($Monate,Val(SubStr($FileDate,6,2))*4-3,3)
$FileDay   = Right("0"+SubStr($FileDate,9,2),2)
$TypeFound = 0

MD (C:\Testing\t1+"\"+$Type)							; create \Type\JAHR\MONAT\Tag 
MD (C:\Testing\t1+"\"+$Type+"\"+$FileYear)
MD (C:\Testing\t1+"\"+$Type+"\"+$FileYear+"\"+$FileMonth)
MD (C:\Testing\t1+"\"+$Type+"\"+$FileYear+"\"+$FileMonth+"\"+$FileDay)

IF Exist ("C:\Testing\t\*.*")
move "C:\Testing\t\*.*" "C:\Testing\t1\"+$Type+"\"+$FileYear+"\"+$FileMonth+"\"+$FileDay"


It moves the files from the current day into the correct direction, but when i tried it with an older file, it moved it into the current day-direction.

I read about FileTime and FileTimeStamp, but i really have no idea, how to use it correct.
Have you guys the time to help me please?
I am quite new in this business, so please dont laugh about me, any beginning is hard.

All replys are welcome,

Thank you very much,

Buhli




Edited by Mart (2012-10-07 12:07 PM)
Edit Reason: Please use code tags when posting code.