Need help with a renamer custom script

Sonarr version (exact version): 3.0.6.1265
Mono version (if Sonarr is not running on Windows): 6.8.0.105
OS: FreeBSD 12.2
Debug logs: sonarr.debug.txt sonarr.txt
Description of issue:
i use Sonnar primary for download anime and then view the show in PMS , and normally i don’t use the rename settings, with the ‘Name of the show/Season x’ its enough, but with a few series its needed to rename the episodes (the few that use absolute number), so i made a custom script to activate ‘on import’ and ‘on upgrade’ and worked flawlessly on v2, but its not working on v3. ithis is the script:

#!/bin/sh
myheader="@/path/to/header.txt"
myenable="@/path/to/enable.json"
mydisable="@/path/to/disable.json"
myCommand="{\"name\":\"RenameFiles\",\"seriesId\":$sonarr_series_id,\"files\":[$sonarr_episodefile_id]}"
echo "Enable Rename"
curl -X PUT -H $myheader --data $myenable "http://sonarrip:8989/api/v3/config/naming"
sleep 5
echo "Renaming..."
curl -X POST -H $myheader --data $myCommand "http://sonarrip:8989/api/v3/command"
sleep 5
echo "Disable Rename"
curl -X PUT -H $myheader --data $mydisable "http://sonarrip/api/v3/config/naming"
echo "Done"

it’s basically:
enable rename settings
rename the episode
disable rename settings

it’s looks like it rename it at the script, when the rename setting are disabled

Thanks

*English it’s not my native language

The rename is queued and your script disables the renaming so when the rename actually executes it does nothing.

sleep 5

This needs to wait for the rename command to complete, you can poll the command API to see that, though rename is queued waiting for the import task to complete (which is the same task that imports the files), you’d need to spawn a new process that handles the renaming so the import task can complete and the rename process can then start.

Alternatively enable renaming and use one of the “original” formats for standard/daily episodes and set your anime (absolute numbered) format appropriately, that’ll make your script obsolete and you won’t have to write a more complex solution.

This

Alternatively enable renaming and use one of the “original” formats for standard/daily episodes and set your anime (absolute numbered) format appropriately, that’ll make your script obsolete and you won’t have to write a more complex solution.

Thanks