Originally Posted By: ryck
Originally Posted By: Hal Itosis
[After all that, i noted the appearance of two files in those (two) Flash Player folders in my home/library:

~/Library/Preferences/Macromedia/Flash\ Player/macromedia.com/support/flashplayer/sys/settings.sol

I deleted that .sol from the folder yesterday and today it re-appeared so I guess it just wants to be there.

Yep... that appears to be Adobe's own pref, for storing our Flash config settings.

Originally Posted By: ryck
Originally Posted By: Hal Itosis
and

~/Library/Caches/Adobe/Flash\ Player/AssetCache/*/cacheSize.txt

I followed that route but, at Asset Cache, mine changed to a folder named NWBY27P9

Yep... everyone will have some randomly named folder there. That's what the /*/ wildcard does... thus allowing my script to work on any Mac (not just mine).

§

Here's the latest rev:
Code:
#!/bin/bash -
# cfc  :::  Clear Flash Cookies
#(c)EF/-HI-2010.Sep.23 [rev:2010.Sep.27]
IFS=$' \t\n'
declare -x PATH=/bin:/usr/bin
declare -i x=0 c=0 k=0
subf= args= list=  s=s
PRG=`basename "$0"`
DR1=~/Library/Preferences/Macromedia/Flash?Player
DR2=~/Library/Caches/Adobe/Flash?Player
PREF=macromedia.com/support/flashplayer/sys/settings.sol
CASH=AssetCache/*/cacheSize.txt

trap tabs EXIT

Help () {
	printf '\e[4mClear Flash Cookies\e[0m\nUsage:\n'
	printf '\t\e[1m%s\e[0m [\e[1m-?\e[0m]\n\n' $PRG
	printf 'Run with no args to list the cookies.\n'
	printf 'Any arg except -h clears the cookies.\n'
	exit 1
}

[ $# -ne 0 ] && [[ $1 = *[Hh]* ]] && Help >&2

Tree () { # print a tree of the cwd:
	local dir= par= ind= fix=
	dir=`pwd -P`; par=`dirname "$dir"`; tabs -5; ind=$'\t'
	[[ $par = / ]] && fix=$ind
	find -x "$dir" -print0 |xargs -0 ls -1dfF |sed 's:'"$par"':'"$fix"':;
		s:/$: \\:;s:[^/]*/:'"$ind"':g;s: \\$:/:;s:'"$ind"':'"$fix"':;
		1s:'"$fix"'::' |sed "s:[/*@=|%]$:`printf '\e[1m&\e[0m'`:"
	tabs
}

GoToFolder () {
	2>/dev/null cd "$1" >&2 && return 0 ||
		printf '\ncannot access folder: %s/\n' "$1" >&2; return 1
}

ScanFolder () {
	GoToFolder "$1" || return 1
	c=`ls -p1 |grep -e '/$' |wc -l |sed 's:[^0-9]::g'`
	subf=`ls -p1 |grep -e '/$' |sed 's:/$::;s: :\?:g'`

	case $c in
	0)	printf '\nno subfolders exist in: %s\n' "$1" >&2; return 1;;
	1)	args=$subf;;
	*)	args=-f\ $subf;;
	esac

	list=`find -x $args -not -type d`

	if [[ -n $list ]]
	then
		[ $k -eq 0 ] && printf '\n\e[7mFILES FOUND:\e[0m'
		printf '\n\e[1;4m%s\e[0;1m/\e[0m\n' "$1"
		echo "$list" |tr '\n' '\000' |xargs -0 ls -legthrob
		((k+=1))
	fi
	return 0
}

for d in $DR1 $DR2; do ScanFolder "$d"; ((x+=$?)); done

printf '\n\n\e[7mTREE LISTING:\e[0m\n'
printf '\e[1;4mPREFS\e[0m\n'
GoToFolder $DR1 && Tree || ((x+=1))
printf '\n\e[1;4mCACHE\e[0m\n'
GoToFolder $DR2 && Tree || ((x+=1))
echo

if [ $# -ne 0 ] && [ $k -ne 0 ]
then  # clear cookies & caches but preserve useful files and directory trees:

	GoToFolder $DR1 &&
	ls -d1 {macromedia.com/support/flashplayer/sys,#SharedObjects/*}/* \
		2>/dev/null |grep -v $PREF |tr '\n' '\000' |xargs -0 rm -fR
	((x+=$?))

	GoToFolder $DR2 && ls -d1 AssetCache/*/* 2>/dev/null |grep -v $CASH |
		tr '\n' '\000' |xargs -0 rm -fR
	((x+=$?))

	[ $x -eq 0 ] && printf '\e[30;42m FLASH COOKIES CLEARED \e[0m\n' >&2
fi

[ $x -eq 1 ] && s=
[ $x -eq 0 ] || printf '\e[37;41m %d error%s occurred \e[0m\n\a' $x "$s" >&2
exit $x


It now preserves those two key files (when we optionally clear the cookies). As always, running with no options will simply list everything, saving us the trouble of rummaging around in Finder (which has the side effect of populating the hierarchy with .DS_Store files).

//

OBS: script was edited again on Monday. As far as finding and/or deleting cookies, nothing was changed. All modifications relate to error detection and reporting, plus minor cosmetic tweaks.

-HI-

For assistance on using shell scripts, see the "Unix FAQ" at hayne.net

Last edited by Hal Itosis; 09/27/10 03:35 PM. Reason: improve error detection & reporting