Deleting images in a folder

422 views
Skip to first unread message

Zahir Namavati

unread,
Dec 17, 2016, 4:05:13 AM12/17/16
to Tasker
Helloo guys,

Am using tasker beginner mode and i need some help with deleting images.

I want to delete all my images say in a particular folder every monday. Is there a way for me to acheive this.

Guys again am using beginner mode so help me accordingly!

Thanks in advance

Pent

unread,
Dec 17, 2016, 6:15:48 AM12/17/16
to Tasker

I want to delete all my images say in a particular folder every monday. Is there a way for me to acheive this.

Create a new profile, select Day, select days of week, Monday.

In the linked task, the simplest action would be to use Run Shell
with the command

rm /path/to/dir/*

Pent

Abdullah Alahdal

unread,
Dec 17, 2016, 6:24:25 AM12/17/16
to Tasker
Easy way as follows

Delete Images (237)
A1: List Files [ Dir:DCIM/Camera Match:*.jpg/*.png Include Hidden Files:Off Use Root:Off Sort Select:Alphabetic Variable:%files_list ]
A2: Stop [ With Error:Off Task: ] If [ %files_list(#) < 1 ]
A3: For [ Variable:%file Items:%files_list() ]
A4: Delete File [ File:%file Shred Level:0 Use Root:Off ]
A5: End For
A6: Notify [ Title:Files Deleted Text:%files_list(#) images were deleted! Icon:null Number:0 Permanent:Off Priority:3 ]


A bit advanced (delete 30 days old images).

Delete Old Files (171)
A1: List Files [ Dir:DCIM/Camera Match:*.jpg//*.png Include Hidden Files:Off Use Root:Off Sort Select:Alphabetic Variable:%files_list ]
A2: Stop [ With Error:Off Task: ] If [ %files_list(#) < 1 ]
A3: For [ Variable:%file Items:%files_list() ]
A4: Test File [ Type:Modified Data:%file Store Result In:%file_date Use Root:Off ]
A5: Variable Set [ Name:%file_age To:(%TIMES-%file_date)/86400 Recurse Variables:Off Do Maths:On Append:Off ]
A6: If [ %file_age > 30 ]
A7: Test File [ Type:Size Data:%file Store Result In:%deleted_files_size Use Root:Off ]
A8: Variable Set [ Name:%total_size To:%deleted_files_size+%total_size Recurse Variables:Off Do Maths:On Append:Off ]
A9: Delete File [ File:%file Shred Level:0 Use Root:Off ]
A10: Variable Set [ Name:%deleted_files To:%deleted_files+1 Recurse Variables:Off Do Maths:On Append:Off ]
A11: End If
A12: End For
A13: Variable Convert [ Name:%total_size Function:Bytes to Megabytes Store Result In: ]
A14: AutoNotification [ Configuration:Title: DCIM Auto Delete!
Text: %deleted_files files were deleted.
Status Bar Icon: ic_action_trash
Number: %deleted_files
Sound: content://media/external/audio/media/21826
Text Expanded: %deleted_files files were deleted and total size recovered is %total_size MB!! Timeout (Seconds):20 ]


Zahir Namavati

unread,
Dec 18, 2016, 3:12:27 AM12/18/16
to Tasker
Hey Abdullah ur easy way worked but there is something that didn't work the way it should. I checked the images after the action ran and they have been deleted from their respective l folder but when I open my gallery those images are still there but now completely black/Grey and I still have to delete them from my gallery! Can u help me on how to get rid of the images as well as those black things in my gallery?

Abdullah Alahdal

unread,
Dec 18, 2016, 3:37:54 AM12/18/16
to Tasker
Hey Abdullah ur easy way worked but there is something that didn't work the way it should. I checked the images after the action ran and they have been deleted from their respective l folder but when I open my gallery those images are still there but now completely black/Grey and I still have to delete them from my gallery! Can u help me on how to get rid of the images as well as those black things in my gallery?

You will need to add Scan Media Action and select the folder you specified in the first action.

Zahir Namavati

unread,
Dec 18, 2016, 8:16:16 AM12/18/16
to Tasker
There is no scan media action but there is a scan card action. I used in the end after notify and used the same folder i did before but the black images still come.

scan card
file:hike/media/hike Images

Ken Stanley

unread,
Jan 3, 2017, 10:52:05 AM1/3/17
to Tasker
Hi Abdullah and/or Zahir,

   I am completely new to Tasker, but am familiar with linux, shell, etc. 
   I am trying to do the same thing, delete image files. I would love to delete only those that are 30 days old, but  for now would be satisfied with just being able to delete all images in a directory. I was able to create a Tasker task that takes pictures at regular intervals by adding a task, setting the time interval and selecting Media -> Take Photo. But in the answer below you seem to be using something that allows more programming control.  

   How do you enter this code?
   What does "Delete Images (237)" mean? 
   
Thanks,
   Ken 

Ken Stanley

unread,
Jan 3, 2017, 11:15:34 AM1/3/17
to Tasker
Hi Pent,

   I am completely new to Tasker but have a few decades of experience with shell commands.
   I found the shell commands, but I can figure out where DCIM is "/DCIM" does not work for me. 
   I also was  unable to execute a "pwd" or "df" command. More to the point I can't find the output from these commands. There is an option to "Store output in" but it won't let me enter anything unless it is a variable or array - I haven't gotten to variables and arrays in Tasker. I just want to see the output somewhere.

   Is it possible to run a shell command interactively? 

conny...@gmail.com

unread,
Jan 3, 2017, 11:39:03 AM1/3/17
to Tasker
try Shell execute "rmdir /DCIM/"

conny...@gmail.com

unread,
Jan 3, 2017, 11:40:00 AM1/3/17
to Tasker
OR try the button Delete Directory
Reply all
Reply to author
Forward
0 new messages