How to name a output file based on input file and a user defined suffix and save the output file to a workspace?

738
3
Jump to solution
05-14-2021 01:33 PM
Labels (3)
badrinathkar
New Contributor III

I am looking for a python code that allows me to name an output file(shapefile/dbf) based on input file +user defined suffix. Thereafter I would like to save the output file to a workspace.

0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor

via command line or as a python script tool?

without more info, something along the lines of:

import os

in_file = arcpy.GetParameterAsText(0)
output_workspace = arcpy.GetParameterAsText(1)
out_suffix = arcpy.GetParameterAsText(2)

out_name = os.path.basename
out_name += out_suffix

out_filepath = os.path.join(output_workspace, out_name)

View solution in original post

3 Replies
DavidPike
MVP Frequent Contributor

via command line or as a python script tool?

without more info, something along the lines of:

import os

in_file = arcpy.GetParameterAsText(0)
output_workspace = arcpy.GetParameterAsText(1)
out_suffix = arcpy.GetParameterAsText(2)

out_name = os.path.basename
out_name += out_suffix

out_filepath = os.path.join(output_workspace, out_name)
badrinathkar
New Contributor III

As a Python script tool.

0 Kudos
DavidPike
MVP Frequent Contributor

So will the above fit into your existing script? do you understand it etc.?

 

0 Kudos