Rename JPEG files to JPG in download folder

100 views
Skip to first unread message

IconBoy

unread,
Apr 12, 2020, 6:24:13 PM4/12/20
to Tasker
I'd like to have Tasker rename any file with .jpeg extension to .jpg in the Download folder any time one gets moved, created or downloaded to that folder.

I tried this:

Rename JPEG (393)
A1: List Files [ Dir:Download Match:*.jpeg Include Hidden Files:Off Use Root:Off Sort Select:Modification Date, Reverse Variable:%jpeg ]
A2: Variable Set [ Name:%max To:%jpeg(#) Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
A3: For [ Variable:%rename Items:1:%max ]
A4: Move [ From:%jpeg(%rename) To:%jpeg(%rename).jpg Use Root:Off ]
A5: End For

but the result ends up like this:

default.jpeg ➞ default.jpeg.jpg

I want it to be default.jpg

Hoping someone can help clarify where I'm doing it wrong. Thanks.

Jimmy Jimmy

unread,
Apr 12, 2020, 9:12:20 PM4/12/20
to Tasker
You need to remove jpeg from the name and add jpg back before you move it.

Basically replace your A4 above with the following 3 actions:

Variable Set [ Name:%new_name To:%jpeg(%rename) Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]

Variable Search Replace [ Variable:%new_name Search:jpeg$ Ignore Case:Off Multi-Line:Off One Match Only:Off Store Matches In Array: Replace Matches:On Replace With:jpg ]

Move [ From:%jpeg(%rename) To:%new_name Use Root:Off ]

IconBoy

unread,
Apr 12, 2020, 10:45:03 PM4/12/20
to Tasker
Thank you. That worked a treat.
I checked the Ignore case in the search and replace variable options and that takes care of the extension being in upper case e.g. .JPEG
I am now getting a toast notification when this runs. (See attachment).
Any way to get that removed if it doesn't find files with .jpeg extensions?

I've also attached the profile xml file in case anyone wants to use it.

Thank you again for helping getting it to work. Much appreciated.

Screenshot_20200412-193532.png
Rename_JPEG.prf.xml

Jimmy Jimmy

unread,
Apr 13, 2020, 9:20:41 AM4/13/20
to Tasker
Add a Stop action if %jpeg(#)=0 after A1 List Files. That should stop the action if there is no match.

IconBoy

unread,
Apr 13, 2020, 2:07:10 PM4/13/20
to Tasker
Whoo-hooo! 👍🏻
Thank you. Works perfectly.

IconBoy

unread,
Apr 14, 2020, 3:36:31 AM4/14/20
to Tasker
Is it possible to monitor the whole device so that any folder that has a file with extension .jpeg would be renamed to. jpg, or is it only possible to watch one folder?
Thanks.
Reply all
Reply to author
Forward
0 new messages