1.

Solve : if exist bgr 100mb?

Answer»

I've a QUESTION.

i need a script that check if a file is bigger then 100MB.
if have 10 folders that contains each 2 files (c:\backup\example1.bak & c:\backup\example2.bak)

each file must be bigger than 100MB

if the file "example.bak" is smaller then 100MB, it must open the explorer.exe, so i can check that pad.
if the size is bigger then i must check the next folder

I'm a noob with dosscript and read some script here, but must i use "if exist" or "errorlevel"
can somebody help me pls with a bat file ?

thx
I think I understand what you are asking. Question: Do you have all 10 of those folders in the same folder with nothing else in it? I.e. Is it setup
C:\BakFiles\Folder1
C:\BakFiles\Folder2
etc...?
The following code will assume that you have it setup the way described above. Please identify if it is not set up in this manner so that the code can be adjusted to fit.

Code: [SELECT]@echo off
setlocal enabledelayedexpansion

cd c:\BakFiles

for /f "delims=" %%F in ('dir /s /b') do (
set path=%%~dpF
set size=%%~zF

if !size! lss 1048576 (
start /wait explorer.exe !path!
)
)

This opens explorer.exe to a folder if any file in that folder is less than 100MB. You will need to close explorer.exe for the script to continue to RUN. If they are not all under one folder, please identify if the locations change on a consistent basis or if they are set locations and not going to change regularly.thank you Raven19528 for your quick response,

i've a few servers and the files are located in different folders/names and different disk (c:, d: and e: )
and there are more files in those folders with other EXTENSION.
but in each folder are only 2 files with extension .bak

what i want to do (if possible) is that i start this .bat file on one of this server and that the script check automatic the other servers
for example a folder:

\\192.168.1.2\C$\backup
\\192.168.1.4\D$\backups\backup1
This is fairly easy to take care of. I would suggest you set up a folder that contains this batch file being written and the following .txt file so that it works as smoothly as possible. Create a new .txt file and type the full path names into it. Normally I would use computer names when you are on a server-client network as it is much more difficult for the computer name to change than the IP address:

>paths.txt
\\Server1\C$\backup
\\Server2\D$\backups\backup1
\\Server3\E$\backupstobackups\bytestobytes


Then use the following script to go through all locations and all files:

Code: [Select]@echo off
setlocal enabledelayedexpansion

for /f "delims=" %%A in (paths.txt) do (
for /f "delims=" %%B in ('dir %%A /s /b') do (
set path=%%~dpB
set size=%%~zB

if !size! lss 1048576 (
start /wait explorer.exe !path!
)
)
)
First it didn't work on my PC (windows 7 64 bit)
but when i tested on a virtual XP machine it works great.
so now i'm going to test it Monday on a windows 2003 and 2008 server.

I'll let you know the results.

thanks



Thx Raven19528,

it works great Raven,

it still works great, but needs some fine tuning

sometimes the path will change by user(s)

now i get sometimes the message "The network path was not found"

is it possible that the script give a output, when a path(s) not exist anymore
or a output .txt from all the succesfull path check ?

thx
This should help.
Code: [Select]@echo off
setlocal enabledelayedexpansion

for /f "delims=" %%A in (paths.txt) do (
IF EXIST "%%A" (
for /f "delims=" %%B in ('dir %%A /s /b') do (
set path=%%~dpB
set size=%%~zB

if !size! lss 1048576 start /wait explorer.exe !path!
)
) else (
ECHO %%A DOES NOT EXIST>>Logfile.Log
)
)Squashman,

sorry for the late respons.

but it's works.

thx for your input



Discussion

No Comment Found