Add the file generated date and time as a suffix to the file name
Overview:
This article provides a solution for users who wish to append the current date and time to the names of files generated from Jira Cloud. The Atlassian Command Line Interface (ACLI) does not directly support this feature, but a workaround using shell scripting is available.
Steps to add the date and time suffix
Basic Use Case
When generating files from Jira Cloud with ACLI, you can append the current date and time to the file name using a compatible shell, such as Bash or Zsh.
Example Command
acli jira --action getProjectList --file "filename_$(date +'%Y%m%d_%H%M%S').txt"Output:
This command will create a file named:filename_YYYYMMDD_HHMMSS.txt.
Use a shell script
Create a shell script that stores the date and time in a variable and then uses it in the file name. An example is displayed below:
#!/usr/bin/env sh
DATE=$(date +'%Y%m%d_%H%M%S')
acli jira --action getProjectList --file "filename_${DATE}.txt"This script generates a file name with the current date and time appended, ensuring easy identification.
Instructions for Windows Users
If you’re running Windows, you can adapt this approach using PowerShell or a Batch script, similar to the following example:
$date = Get-Date -Format "yyyyMMdd_HHmmss"
acli jira --action getProjectList --file "filename_$date.txt"This command produces a file with a name similar to:
filename_YYYYMMDD_HHMMSS.txt
Common issues and troubleshooting
Issue: Command Not Working in ACLI Shell
ACLI’s interactive shell does not support shell scripting or command substitution. To use this workaround, run ACLI commands in a compatible shell environment, such as Bash, Zsh, or PowerShell.
Example: Generate a project list with the current date and time.
Redirect to ACLI directly from the terminal (not through ACLI).
Enter the following command:
acli my-jiracloud --action getProjectList --file "filename_$(date +'%Y%m%d_%H%M%S').txt"output “/Users/test/filename_20241028_180606.txt“
The file name contains the: year/month/date_currentdate/time/seconds