bitcoinTrader (OP)
|
|
February 13, 2012, 04:40:35 AM Last edit: February 14, 2012, 07:36:46 AM by bitcoinTrader |
|
Hi,
I require simple windows batch script to do the following:
If the file is older than 2 minutes in a particular folder, copy the file to another location.
Should be easy job.
Please post here or PM.
Thanks!
|
|
|
|
mb300sd
Legendary
Offline
Activity: 1260
Merit: 1000
Drunk Posts
|
|
February 13, 2012, 04:58:31 AM Last edit: February 13, 2012, 08:12:42 AM by mb300sd |
|
Not particulrly good with batch files, but if your running on Vista or 7, this powershell script should do it.
$files=get-childitem . $date = get-date $date = $date.AddMinutes(-2) foreach ($file in $files) { if ($date -lt $file.LastWriteTime) { copy $file dir\ } }
|
1D7FJWRzeKa4SLmTznd3JpeNU13L1ErEco
|
|
|
bitcoinTrader (OP)
|
|
February 13, 2012, 05:20:17 AM |
|
Sorry, require simple batch script, not powershell.
I want to run the script on Windows Server 2003.
|
|
|
|
|
btc_artist
Full Member
Offline
Activity: 154
Merit: 102
Bitcoin!
|
|
February 13, 2012, 07:26:41 AM |
|
|
BTC: 1CDCLDBHbAzHyYUkk1wYHPYmrtDZNhk8zf LTC: LMS7SqZJnqzxo76iDSEua33WCyYZdjaQoE
|
|
|
bitcoinTrader (OP)
|
|
February 13, 2012, 08:42:47 AM |
|
Already tried that, doesnt work.
|
|
|
|
BinoX
|
|
February 13, 2012, 01:38:37 PM |
|
Any particular reason you want it to be a batch script rather than a simple exe file? (If you would be happy with an exe I can make you one in about 2 or 3 mins)
|
|
|
|
bitcoinTrader (OP)
|
|
February 13, 2012, 02:17:13 PM |
|
I want to run from Control M software. I have never executed exe, only bat and sh files
Is there much difference between exe and bat files?
|
|
|
|
BinoX
|
|
February 13, 2012, 02:21:03 PM |
|
If you can run bat files you should be able to run exe files.
If you can't do it directly then you could always put the exe file on the machine and then run it from a bat
|
|
|
|
bitcoinTrader (OP)
|
|
February 13, 2012, 02:27:54 PM |
|
I assume if exe can be made, batch can also be made with same commands, right?
|
|
|
|
BinoX
|
|
February 13, 2012, 02:30:42 PM |
|
An exe file is different. It's a complied program rather than a script.
There probably IS a way to do it with a .bat file, but I don't think it will be as simple as it seems
|
|
|
|
bitcoinTrader (OP)
|
|
February 13, 2012, 02:32:37 PM |
|
Can you do it in batch? How much will you charge for that?
|
|
|
|
BinoX
|
|
February 13, 2012, 02:36:00 PM |
|
Can you do it in batch? How much will you charge for that?
To be honest, I'm not 100% sure that I would be able to do it as a batch file, it's been a long time since I've done any proper batch file creation (since I usually just write programs to do things these days) If I find a solution, I will let you know
|
|
|
|
bitcoinTrader (OP)
|
|
February 13, 2012, 02:46:54 PM |
|
BTW, in which language can you make exe? Also, source will be available?
|
|
|
|
eroxors
Legendary
Offline
Activity: 924
Merit: 1000
Think. Positive. Thoughts.
|
|
February 13, 2012, 04:38:48 PM |
|
Not sure if this will work for you, but it copies all files every 2 minutes (120 seconds) 720 times (1 day), regardless of age. You can then set the batch to run with windows task manager once a day.
@echo off for /L %%a in (1,1,720) do ( xcopy /d /y /c c:\folder1\*.* c:\folder2\ ping localhost -n 120 > nul )
|
|
|
|
BinoX
|
|
February 13, 2012, 05:22:54 PM |
|
BTW, in which language can you make exe? Also, source will be available?
For little utilities like this I use a language called purebasic (see www.purebasic.com for details) It's a great language to use for any small tools that you want written quickly. And yes, source code would be available
|
|
|
|
bitcoinTrader (OP)
|
|
February 13, 2012, 05:32:00 PM |
|
Not sure if this will work for you, but it copies all files every 2 minutes (120 seconds) 720 times (1 day), regardless of age. You can then set the batch to run with windows task manager once a day.
@echo off for /L %%a in (1,1,720) do ( xcopy /d /y /c c:\folder1\*.* c:\folder2\ ping localhost -n 120 > nul )
This is kind of scheduler, but I already have scheduled job running via control m. I want 2 min old files to be copied.
|
|
|
|
Bitsky
|
|
February 13, 2012, 05:56:47 PM |
|
Write the program in any language you want and compile it if needed. Then just call it from within a batch script by using "START". Or maybe I don't see your problem here...
|
|
|
|
gutschilla
Newbie
Offline
Activity: 17
Merit: 0
|
|
February 13, 2012, 07:57:25 PM |
|
My solution would be a small c++ program that outputs every file in a given directoy that's older than 2 minutes. You would have to place this program somewhere in your $PATH. Then you would be able to create a batch file that simply copies each file somewhere. Do you have access to your machine in a way to install programs (I mean, just putting an .exe in your windows folder)?
|
|
|
|
mb300sd
Legendary
Offline
Activity: 1260
Merit: 1000
Drunk Posts
|
|
February 14, 2012, 02:43:43 AM |
|
If you can install software, you cal always use the above script i posted, just install powershell ( http://support.microsoft.com/kb/968929 ) and make a batch file with "powershell -File aboveScript.ps1"
|
1D7FJWRzeKa4SLmTznd3JpeNU13L1ErEco
|
|
|
|