D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] Find and Delete in Terminal

 

Hi Richard,

Richard Brown <rich@xxxxxxxxxxx> writes:

> Hi All
>
> I am cleaning up a load of photos and I have found there seems to be a
> lot of .json files in amongst all the photos. Is it possible to write
> a terminal search of a folder and all it's sub-folders that will clear
> out all the json files please?
>
> Thanks
>
> Rich
> --
> Kind Regards
> Richard Brown
> Learning the unforced rhythms of grace
> https://gwyls.co.uk/
> https://gucu.org.uk/

I would approach this problem with the `find` command.

You want all the JSON files to be removed, so I would run this command
*in* the folder - do not run it outside of this folder, as it will
clear all files that have the .json extension.

The command I propose is:

`find ./ -type f -iname '*.json' -print -delete`

This will recursively find all files that have the .json extension,
and delete them, whilst *also* printing each file to the console. You
can omit `-print` if you do not want that to happen.

The `-iname` part matches all .json files that might have capital
letters in them as well, but if they don't, you can just use `-name`
instead :-)

(Disclaimer: running this command is at your *own risk*, and I do not
take liability for any unintentional data loss because of it. I
recommend making a backup of the photo folder first.)

I'm interested though, are these photos from just a camera? Never
really seen photos accompanied with a JSON file as well. Might be
metadata.. though...

I hope this helps.

--
Sincerely,
Dom Rodriguez (shymega/dzr).

-- 
The Mailing List for the Devon & Cornwall LUG
https://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq