Skip to main content
Solved

Renaming File With No Extension

  • May 22, 2023
  • 1 reply
  • 229 views

Forum|alt.badge.img

I need to be able to change a filename of an outbound file to the following naming convention MOT599XXXX.CCYYMMDDHHMMSSNN using the current date and not adding a file extension. Any pointers on getting this done?

Best answer by James B

You would want to rename the file before it is passed to whatever connector is being used for transport here, which you can do through a simple Script connector. 

 

<!-- reference original file contents -->
<arc:set attr="output.filepath" value="[filepath]" />
<!-- overwrite filename -->
<arc:set attr="output.filename" value="MOT599XXXX.[now('yyyyMMddHHmmssff')]" />
<!-- pass out file -->
<arc:push item="output" />

 

A few notes:

  • I’m assuming NN is fractions of a second. In Windows, this time format is ff - in Java it is SS
  • HH returns the hour in 24 hour format - hh is 12 hour
This topic has been closed for replies.

1 reply

James B
Forum|alt.badge.img
  • Employee
  • Answer
  • May 26, 2023

You would want to rename the file before it is passed to whatever connector is being used for transport here, which you can do through a simple Script connector. 

 

<!-- reference original file contents -->
<arc:set attr="output.filepath" value="[filepath]" />
<!-- overwrite filename -->
<arc:set attr="output.filename" value="MOT599XXXX.[now('yyyyMMddHHmmssff')]" />
<!-- pass out file -->
<arc:push item="output" />

 

A few notes:

  • I’m assuming NN is fractions of a second. In Windows, this time format is ff - in Java it is SS
  • HH returns the hour in 24 hour format - hh is 12 hour