What is the best way to go about this? I'm able to do it with a single file as below, but what if I would like to copy all files with .txt to a folder, and all files with .docx to another folder. I tried changing in_data to just .txt but this did not work.

# Import system modules
import arcpy

# Set workspace
arcpy.env.workspace = "C:\Users\X220\Documents"

# Set local variables
in_data =  "test.txt"
out_data = "C:\Users\X220\Documents\output\Copy.docx"

# Execute Copy
arcpy.Copy_management(in_data, out_data)

closed as off-topic by FelixIP, Fran Raga, user2856, Hornbydd, Vince Jun 10 at 11:25

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions relating to general IT or with no clear GIS component, are off-topic here but can be researched/asked at Stack Overflow (software development), Super User (computing hardware and software), Database Administrators (relational databases) and other SE sites" – FelixIP, Fran Raga, user2856, Hornbydd, Vince
If this question can be reworded to fit the rules in the help center, please edit the question.

  • Usually when multiple copying, /*.extension used. Did you try in_data = "*.txt"? and out_data is a directory – Jane Jun 10 at 8:01
  • Tried that and got: ERROR 000732: Input Data: Dataset *.txt does not exist or is not supported – Alex Hunter Jun 10 at 9:34
  • 1
    maybe this helped stackoverflow.com/a/296184/8129993 – Jane Jun 10 at 10:32
  • ArcGIS 10.0 has been retired for a long time. The Python that shipped with it is ancient. If you are using a modern release, please Edit the question body and tag. – Vince Jun 10 at 10:45
  • import os, glob then for f in glob.glob(os.path.join(in_path, '*.txt'))): – user2856 Jun 10 at 11:03

Browse other questions tagged or ask your own question.