Topic Options
#1401 - 03/17/07 09:05 PM Move_on_Date.tg HELP
GrapeApe Offline
Junior Member

Registered: 03/17/07
Posts: 7
I am trying to get the move_on_date.tg working and I am having trouble. I am running win xp and wincron 4.3 the dated files are .txt files , if my .txt files path is c:/hfslog/ then where do I insert that into the move_on_date script (c:\file_store\*.* THE_FILE) maybe where the file_store is ? Also where it says THE_FILE should I be changing that to something.Yes I am very new.
I found this in one of the post and it is exactly what I needed THX
{
-name delete
-start -inc 0 0 0 10
-action -onerror break
-action -getFile -oldest "c:\HFSLog\*.*" THE_FILE
-action -print deleting %THE_FILE%
-action -del "%THE_FILE%"
}

Sorry for posting twice and basically answering my own questions should have looked a little longer.


Edited by GrapeApe (03/17/07 10:34 PM)

Top
#1402 - 03/18/07 07:24 PM Re: Move_on_Date.tg HELP [Re: GrapeApe]
Luke Tomasello Administrator Offline
Member

Registered: 09/17/00
Posts: 740
Loc: San Jose, CA., USA
Well, you are missing lot of important code \:\)
THE_FILE is not a file name THE_FILE.NAME is the file name.
THE_FILE.AGE is the age.

You need the rest of the script to check the date (AGE) and make a decision weather or not you want to delete it.

In your example above above, what constitutes an old file? 5 days? 30 days? 3 years?
You need to have the logic in there that makes a decision based on the date:

 Code:
## move_on_date.tg 
# So, how exactly do I move / delete a file at/over x-days-old? 
# 

{ 
        -name move_on_date
        # fire every second 
        -start -inc 0 0 0 1 

        # if there are no more files, break 
        -action -onerror no_more_files 

        # get the next file, if there are no more files 
        #  we will stop here 
        -action -getfile -newest c:\file_store\*.* THE_FILE 

        # okay, check to see if the files age in days is greater than 15
	#  if so, move to the old_files folder, otherwise, move to the 
	#  temp_folder. 
	# Files in the temp folder will be restored in the no_more_files procedure
        -action -onerror temp_files 
        -action -test "%THE_FILE.AGE.DAYS% > 15" 
        -action -call old_files 

} 

## no_more_files
# Files in the temp_folder will be restored to their original location in this procedure
{ 
        -name no_more_files 
        -action -print there are no more files. restoring from temp dir... 
	-command -hide CMD.EXE /c MOVE /Y "c:\file_store\temp_files\*.*" "c:\file_store" 
        -action -return break 
} 

## temp_files
# move 'NON-OLD' files to a temp folder
{ 
        -name temp_files 
        -action -print temp_files 
        -action -move "%THE_FILE%" "c:\file_store\temp_files\%THE_FILE.FNAME%%THE_FILE.EXT%" 
        -action -return break 
} 

## old_files
# move 'OLD' files to a old_files folder
{ 
        -name old_files 
        -action -print old_files 
        -action -move "%THE_FILE%" "c:\file_store\old_files\%THE_FILE.FNAME%%THE_FILE.EXT%" 
        -action -return break 
} 
_________________________
Regards,
Luke Tomasello

Top
#1403 - 03/18/07 07:54 PM Re: Move_on_Date.tg HELP [Re: GrapeApe]
GrapeApe Offline
Junior Member

Registered: 03/17/07
Posts: 7
Yeah I figured that out Ive learned so much in that past couple of days This is what I've come up with and ANY suggestions are welcome(by the way how did you get your code in the box in your post?).
Wincron is a very cool tool
Thx again

 Code:

{
-name move_job
-start  -time 10:00 AM -constrain 0 0 0 10
-action -onerror break
-action -getFile -oldest "c:\HFSLog\*.*" THE_FILE 
-action -test "%THE_FILE.AGE.DAYS% > 7"
-action -print Moving Files %THE_FILE%
-action -move "%THE_FILE%" "c:\HFSLog\OLDLog\%THE_FILE.FNAME%%THE_FILE.EXT%" 
-action -call move_job
} 


{
-name old_files
-start -cron 55  09  *  *  1  
-action -onerror break
-action -getFile -oldest "c:\HFSLog\OLDLog\*.*" THE_FILE 
-action -test "%THE_FILE.AGE.DAYS% > 30"
-action -print Deleteing OLDLogs  
-action -del "%THE_FILE%" 
-action -call old_files
}


Off topic but I have two questions as well, If I use this script( -command -shell c:\windows\media\Chord.wav ) how do I get the media player GUI not to open and if not ( which leads to my second question ) how do I close a process with wincron? Ive seen a couple of couple of post on this subject I'm still not sure.

Top
#1404 - 03/18/07 08:17 PM Re: Move_on_Date.tg HELP [Re: GrapeApe]
Luke Tomasello Administrator Offline
Member

Registered: 09/17/00
Posts: 740
Loc: San Jose, CA., USA
by the way how did you get your code in the box in your post

Just put code tags around it
[code)
code here!
[/code)

instaed of the ')' use ']'

First off,
-command -shell chord.wav
has been replaced by:
-action -spawn -shell c:\windows\media\Chord.wav

so, try
-action -spawn -shell -hide c:\windows\media\Chord.wav

or maybe
-action -spawn -shell -minimize c:\windows\media\Chord.wav

and if that doesn't work, try
-action -spawn -hide c:\windows\media\Chord.wav
_________________________
Regards,
Luke Tomasello

Top
#1405 - 03/18/07 08:44 PM Re: Move_on_Date.tg HELP [Re: Luke Tomasello]
GrapeApe Offline
Junior Member

Registered: 03/17/07
Posts: 7
Thx for the response.This script ( -action -spawn -shell -hide c:\windows\media\tada.wav ) works great to hide the player but when I check my process explorer the media player is still running and if I have multiple jobs with multiple .wavs it opens up a new media player for each .wav which in the long run could be a problem. Any suggestions?

Top
#1406 - 03/19/07 08:18 AM Re: Move_on_Date.tg HELP [Re: GrapeApe]
Luke Tomasello Administrator Offline
Member

Registered: 09/17/00
Posts: 740
Loc: San Jose, CA., USA
right, I would look to see if there is a commandline that says "play this file and exit".

If not, you can look at the SendKeys functionality to close it via it's own interface.

Another possibility is to write your own little one line .EXE that plays the file and exits! the windows SDK has a function that's called something like PlayFile(path); that you could pass the commandline, then exit .. it would be litterally one line of code.
_________________________
Regards,
Luke Tomasello

Top
#1407 - 03/19/07 09:02 AM Re: Move_on_Date.tg HELP [Re: Luke Tomasello]
GrapeApe Offline
Junior Member

Registered: 03/17/07
Posts: 7
I was trying to use sendkeys and at the end of the line of code (which of course I cant find now ) I had this (fc) (Which I assume is file and close ) and I can see the file window open on the media players gui (it opens like someone clicked on file) but then I get a windows error sound and it doesnt close. This may be dumb question but at the bottom after clicking file is exit not close

Top
#1408 - 03/19/07 09:09 PM Re: Move_on_Date.tg HELP [Re: GrapeApe]
GrapeApe Offline
Junior Member

Registered: 03/17/07
Posts: 7
Evidently you get asked about killing processes a lot and I see thats not wincrons intended purpose. I took your last suggestion but I didn't make the .exe. I found a command line process killer and this is what I came up with and everything seems to running fine.
{
-name kill_job
-action -spawn -hide c:\processkill.exe -q vlc.exe
-action -onerror break
}
Just foe entertainment purposes a .wav is played when a file is deleted or moved and as stated b4 I end up with a process running (vlc.exe) for each move or delete action , calling the above job gets rid of all of them.

Top
#1409 - 03/20/07 07:09 AM Re: Move_on_Date.tg HELP [Re: GrapeApe]
Luke Tomasello Administrator Offline
Member

Registered: 09/17/00
Posts: 740
Loc: San Jose, CA., USA
yep, I think that's a reasonable solution.
SendKeys is great and all that, but it's different for nearly every program. This means you really need to sit down and spend some time with it when process kill is easy.
_________________________
Regards,
Luke Tomasello

Top


Moderator:  Luke Tomasello