|
Answer» Hello everyone
I read for a couple of hours some really interesting topics ... very very nice forum you have here ...
I have also a problem ... sorry to start with that ... it's about doing a batch file that :
1. Finds the filesize in kb,mb,bytes, whatever of a SQL database(or any other file.. why not) 2. If the file is over 4GB(or let's say 3.999 ) -------------------------------- The steps 1. and 2. will be probably a windows service ... to PERMANENTLY monitor the file size in a continuous loop. This could be done also without a service .. just using the windows SCHEDULER from 24h/24h -------------------------------- 3. Do a move commnad elsewhere on the hard-drive 4. Done
It's very difficult to me managing by myself ... that's why I hope receiving answer from experts like you.
This is my code since now :
--------------------------------- for /f %%a in ('E:\Progra~1\PowerMeasurement\IONEnterprise\Database\SystemLog\ION_SystemLog.mdf /b') do goto xxx
:xxx echo ddddd if %%~za GTR 30 backup E:\Progra~1\PowerMeasurement\IONEnterprise\Database\SystemLog\ION_SystemLog.mdf c:\ ---------------------------------
And one more question... is there a way that the "for" statement above won't open autommaticaly the file ... I hate that ... it supposed to be a automatic batch file. ... {JOKE} rem JOKE
If you have any idea on how to do this or have you seen it elsewhere ... i'll apreciate
Thank you in advance
Code: [Select]for /f %%a in ('E:\Progra~1\PowerMeasurement\IONEnterprise\Database\SystemLog\ION_SystemLog.mdf') do ( echo ddddd if %%~za GTR 30 backup %%a C:\ )Right now, this batch file just gets ION_SystemLog.mdf, echoes ddddd (um... why?), and if the file is larger than 30 bytes, backs it up (does backup work? If not, try copy).
What, specifically, do you want? Because what's happening right now isn't really much... does for really open the file?QUOTE from: Dark Blade on July 24, 2007, 01:11:35 AM does for really open the file? It does if you put a filename in single quotes like that, which is the way that you execute a program or start a program associated with a file.
For example...
for /f %%a in ('anyname.doc') do ( echo %%a )
That is the same as typing "anyname.doc" at the prompt, and will open the file, if it exists, in the program associated with the .doc extension, on my system this is Microsoft Word.
Leave out the quotes, Victor, if you want to avoid opening the file!
Also you should learn when to use /f and when not to, and what the "delims=" does.
|