Created
May 4, 2018 03:23
-
-
Save tralston/bb1fb5f1ebb4592c3d194de204e9d43c to your computer and use it in GitHub Desktop.
Find folders recursively from parent folder in PhotoSweeper X #sql #sqlite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- PhotoSweeper X database (sqlite3) is located in: | |
-- ~/Library/Containers/com.overmacs.photosweeperpaddle/Data/Library/Application Support/PhotoSweeper X/Library.pslib | |
-- First query gives all folderids that are subfolders of folderid 351 | |
CREATE TABLE folders WITH RECURSIVE folds(x) AS (VALUES(351) UNION SELECT folderID FROM PSFolder, folds WHERE PSFolder.parentFolderID=folds.x) SELECT * FROM folds ORDER BY x; | |
-- If you're curious how many files are in this folder structure, run this | |
SELECT count(*) FROM PSFile WHERE parentFolderID IN folders; | |
-- Second command deletes all files that have parentFolderIDs in that list | |
DELETE FROM PSFile WHERE parentFolderID IN folders; | |
-- Make sure to delete the table | |
DROP TABLE folders; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment