Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MKS Toolkit Scripting using sh.exe

Status
Not open for further replies.

Jumbo

Technical User
Aug 25, 2000
5
US
I've written a small script which checks if the archive attribute has been cleared and if so deletes the file. Does anyone know how to check the file attributes of an entire directory and delete only non archives files ?

i'm using the -k option within the korn shell
 
I'm not sure how you check that archive attribute using MKS sh.exe, but here's a generic loop that should work once you stick your attribute check in the appropriate place. The code that does the attribute check should return a TRUE value if the archive bit is set for this code to work.
[tt]
#!/bin/sh

# Replace with the correct path.
cd /dir/to/clear/down

# Loop around the names of every file in the directory.
# For every file, $file will be set to the current
# file name.
for file in *
do
# Check if the archive attribute is set. Use $file
# as the filename to check.
if [ Put your attribute check in here ]
then
rm $file
fi
done
[/tt]

Hope this helps.
 
Yes, thanks...it was exactly what i was trying to do.

Appreciate it..
Jumbo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top