[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Missing Operand

Posted on 2006-06-06
3
Medium Priority
?
1,448 Views
Last Modified: 2008-03-17
I am trying to to create a script that I can use to delete files that are older that x days (at least)

My test code so far is

set homedir=C:\temp
for /f "tokens=2-4 delims=/ " %%a in ("%date%") do set /a Y=1%%c-10000&set /a M=1%%b-101&set /a D=1%%a-101
set /a TimeNow=12*31*%Y% + 31*%M% + %D%
for /r "%homedir%" %%f in (*) do (
for /f "tokens=1-3 delims=/ " %%a in ("%%~tf") do set /a Y=1%%c-10000&set /a M=1%%a-101&set /a D=1%%b-101
set /a TimeFile=12*31*%Y% + 31*%M% + %D%
set /a TimeDiff=%TimeNow% - %TimeFile%
)
PAUSE
exit

Problems I am have is
   for /f "tokens=1-3 delims=/ " %%a in ("%%~tf") do set /a Y=1%%c-10000&set /a M=1%%a-101&set /a D=1%%b-101  
 
   Returns Missing operand

A second issue I have is
   I would like to replace the following  code
     for /r "%homedir%" %%f in (*) do (

   with a for statement that executes for a single directory rather than each directory of the tree

Thanking you all in advance

0
Comment
Question by:reccles
1 Comment
 
LVL 30

Accepted Solution

by:
SteveGTR earned 500 total points
ID: 16849381
Try this:

@echo off

setlocal enabledelayedexpansion

pushd C:\temp

for /f "tokens=2-4 delims=/ " %%a in ("%date%") do set /a Y=1%%c-10000&set /a M=1%%b-101&set /a D=1%%a-101
set /a TimeNow=12*31*!Y! + 31*!M! + !D!
for /f "delims=" %%f in ('dir /b /a-d 2^>NUL') do (
for /f "tokens=1-3 delims=/ " %%a in ("%%~tf") do set /a Y=1%%c-10000&set /a M=1%%a-101&set /a D=1%%b-101
set /a TimeFile=12*31*!Y! + 31*!M! + !D!
set /a TimeDiff=!TimeNow! - !TimeFile!
)

popd

Good Luck,
Steve
0

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question