Firstly, one of the lines of your script is split over two lines, this could be the syntax error... Also the line if fc <> os.path.basename(clipFeatures): might be better as if fc != os.path.basename(clipFeatures): - that is ! (not) = (equal). Here is an edited version of your script to include these changes:# Script Name: Clip Multiple Feature Classes
# Description: Clips one or more shapefiles
# from a folder and places the clipped
# feature classes into a geodatabase.
# Created By: Me.
# Date: 082711.
# Import ArcPy site-package and os modules
#
import arcpy
import os
# Set the input workspace
#
arcpy.env.workspace = arcpy.GetParameterAsText(0)
# Set the clip featureclass
#
clipFeatures = arcpy.GetParameterAsText(1)
# Set the output workspace
#
outWorkspace = arcpy.GetParameterAsText(2)
# Set the XY tolerance
#
clusterTolerance = arcpy.GetParameterAsText(3)
try:
# Get a list of the featureclasses in the input folder
#
fclist = ("S_R04_FIF.ActivityPolygon","S_R04_FIF.GeosciSri")
for fc in fclist:
# Validate the new feature class name for the output workspace.
#
featureClassName = arcpy.ValidateTableName(fc + "_Clip", outWorkspace)
outFeatureClass = os.path.join(outWorkspace, featureClassName)
# Clip each feature class in the list with the clip feature class.
# Do not clip the clipFeatures, it may be in the same workspace.
#
if fc != os.path.basename(clipFeatures):
arcpy.Clip_analysis(fc, clipFeatures, outFeatureClass, clusterTolerance)
except:
arcpy.AddMessage(arcpy.GetMessages(2))
print arcpy.GetMessages(2)
Now, the reason it doesn't work from the command line is that you need to enter everything from both the Try and the Except statements before getting the interpreter to run it, as well as the indented blocks within those...You shouldn't really run much from the interpreter (command line), especially not something this complex - you need to make a Python script, then set up Python to run it.First off, go to Run, enter cmd and hit enter (this brings up the command prompt), then type python and hit enter. This may (but probably won't - see the instructions below) start the Python interpreter, like so:C:\>python
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)
Type "help", "copyright", "credits" or "license" for more information.
>>>
If that works, you can skip this paragraph, if not here are the instructions of how to set up your Python:[INDENT]NOTE: Doing this requires administrator rights on the computer you are using.Add the ArcGIS Python installation to your systems Environment Variable Path. To do this you need to know where ArcGIS has installed its Python - search your system for python.exe and write down the path and folder it lives in. For example, on my system, it is C:\Python26\ArcGIS10.0\WARNING: Donâ??t make any mistakes here (like deleting things), or your system might not workâ?¦Now, on Windows XP:[INDENT]Right click on My Computer, select Properties, go to the Advanced tab, then click Environment Variables[/INDENT]On Windows 7 (and, I presume, Vista):[INDENT]Right click on Computer, click on Advanced system settings on the left, then click Environment Variables[/INDENT]In the â??System variablesâ?? pane, scroll the box down and select the â??Pathâ?? variable, then go to Edit. Place the cursor in the box, and hit End to get the cursor at the end, add a semi-colon ( ; ) and then enter the path to the Python installation that you wrote down earlier. So, on my computer, I added this:[INDENT];C:\Python26\ArcGIS10.0\[/INDENT]Click OK, then close the other dialog boxes... To test it works, try opening python from the command prompt again.[/INDENT]Now, save your file somewhere as 'myClip.py' or something like that, then navigate the command prompt to the folder containing the file (using cd), and enter:python myClip.py
This will possibly show some other errors if your paths aren't set up correctly or if there are other underlying problems in your script. Anyway, at least you can properly test the script now...