Skip to main content
Question

How to change file name of downloaded file.

  • March 22, 2023
  • 2 replies
  • 180 views

shomber2
Contributor
Forum|alt.badge.img

I am currently working on a workflow that downloads a file from ArcGIS Online and I am then uploading the attachment to Cityworks via the API. The file is downloaded with a general name and I'd like to change the name of the file before passing to the API. I have done some digging on this forum and I am not seeing a way to dynamically change the file name based on other attributes in the middle of a workflow. Would I have to build a custom transformer to do this? Any ideas or examples appreciated, thanks!

2 replies

warrendev
Enthusiast
Forum|alt.badge.img+26
  • Enthusiast
  • 121 replies
  • March 22, 2023

Hi @shomber2​ ,

A few ways come to mind when manipulating files. If you have the filename in an attribute within your workflow, you could use a Filecopy FeatureWriter with the "Move" setting by providing it with the full path. Another option would be to use a PythonCaller or even the SystemCaller.

 

Here is a post going over some of these options.

Is there a quick way to rename files? (safe.com)

 

Python File Operations

os — Miscellaneous operating system interfaces — Python 3.11.2 documentation

shutil — High-level file operations — Python 3.11.2 documentation

 

 

 

 


shomber2
Contributor
Forum|alt.badge.img
  • Author
  • Contributor
  • 1 reply
  • March 23, 2023

Hi,

 

Thanks for the quick reply!

 

I was able to achieve the result I was looking for using PythonCaller. Below is a screenshot of the code if anyone else comes across this.

 

image