Renaming the File Attachments from Old Jira Version
Platform Notice: Cloud and Data Center - This article applies equally to both cloud and data center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problem
After migrating from Jira Server to Jira Cloud, some attachments are broken due to different format of the file name in old Jira version.
This usually happens when Jira Server was running Jira 4.2 or earlier, then upgraded the version to the latest version.
Cause
In older version of Jira, the attachments are named as id_filename (Jira 4.2 and earlier). However, attachments are named only with IDs on the latest version of Jira (including Jira Cloud).
Even after upgrading Jira to the latest version, the old attachments remain with the old formatting,id_filename
Example:
Old format:
New format:
Resolution
Prerequisites
Need to make sure that 'rename' package is installed
1 2 3
Command 'rename' not found, but can be installed with: sudo apt install rename
Steps:
Save the following code block into a file and name it
rename.sh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#!/bin/bash echo "Renaming the files..." rm -f rename.txt find -name "* *" -type f | rename 's/ /_/g' filenames=`find "$PWD" -type f | grep "_"` filenames_arr=(`echo $filenames | tr ' ' ' '`) len=${#filenames_arr[@]} for (( i=0; i<$len; i++ )); do filename="${filenames_arr[$i]}" filename_arr=(`echo $filename | tr '_' ' '`) newfilename="${filename_arr[0]}" if [[ $filename == *"thumb"* ]]; then echo "Not renaming thumbnail files" >> rename.txt echo $filename >> rename.txt echo "======================================================" >> rename.txt else echo "Renaming thumbnail files" >> rename.txt echo $filename >> rename.txt echo $newfilename >> rename.txt mv $filename $newfilename echo "======================================================" >> rename.txt fi done echo "Done!"
Place the script within the data folder
Run the script:
1
$ ./rename.sh
You would notice a log file called rename.txt is then added to the directory
Was this helpful?