You'd need to create two files -- plain text ones -- with those commands in them. The actual files would be:
saveicon.sh:
Code:
#!/bin/sh
# Save volume icon
if [ -e "$4/.VolumeIcon.icns" ]; then
cp "$4/.VolumeIcon.icns" "/tmp/$3.VolumeIcon.icns"
fi
restoreicon.sh:
Code:
#!/bin/sh
# Restore volume icon
if [ -e "/tmp/$3.VolumeIcon.icns" ]; then
cp "/tmp/$3.VolumeIcon.icns" "$4/.VolumeIcon.icns"
if [ -e /Developer/Tools/SetFile ]; then
/Developer/Tools/SetFile -a C "$4" # Set "custom icon" flag for volume
fi
rm -f "/tmp/$3.VolumeIcon.icns"
fi
These would have to be saved in those files, then each would have to be marked as executable. That would involve a command in Terminal (assuming they're in your Home fodler):
Code:
chmod +x ~/saveicon.sh ~/restoreicon.sh
Thanks for the other comments.