Bottom Page

Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Looping through files, check content and delete
#1
Dear Python Experts,

I wonder if it is possible to write a small python program
that goes through my 50 000 .json files on my windows machine and deletes every .json file that conains "throttle":"0" or "throttile":"0.0"
as well as an image that is in the same folder and named in the .json file "cam/image_array": "xxxxxxxxx.jpg"

I imagine looping through all .json files and if the pattern is found, extracting first the image name and deleting the image
and second deleting the json file, then go to next file.

Is something like that possible?
Quote
#2
yes. you will need the json module from standard library to read the json files.
there are multiple different ways to iterate over files.
metalray likes this post
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  How do I read the HTML files in a directory and write the content into a CSV file? glittergirl 1 145 Sep-23-2019, 11:01 AM
Last Post: Larz60+
  Looping through music files (SOLVED) ebolisa 0 220 Jul-13-2019, 06:16 PM
Last Post: ebolisa
  Delete Lines that Contain Words - Loop through files in a folder - Write to new files dj99 3 443 May-18-2019, 06:34 AM
Last Post: heiner55
  How to concatenate files while looping through lists? python_newbie09 3 388 Mar-24-2019, 03:11 PM
Last Post: python_newbie09
  Delete multiple files using file extention sumncguy 2 451 Jan-23-2019, 03:05 AM
Last Post: snippsat
  Looping through csv files in a folder WhatsupSmiley 3 1,727 Nov-13-2018, 08:39 PM
Last Post: Larz60+
  Delete files inside Folder and subfolders zinho 5 6,567 Jun-27-2017, 08:55 PM
Last Post: wavic
  Looping .xlsx files in folder/subfolders copy pasting currentregion HarrisQ 4 2,235 Apr-17-2017, 06:35 AM
Last Post: HarrisQ

Forum Jump:


Users browsing this thread: 1 Guest(s)