I recently had an issue with Google Drive which resulted in a large number of duplicate files and folders being created. On Google Drive, confusingly, these folders actually have the same name, but in my local directory structure (synced using InSync HQ) the folders and files are properly renamed to “name (2)”.

Now tracking all of these down via a GUI file explorer was just going to be painful. I could probably utilise some package for duplicate file checking but I wanted to play around with my command line skills a bit and came up with the following solution for backing up these files that had “(2)” appended, and then deleting them.

Comments

Donncha

Nice. I used a complicated loop to mkdir -p, dirname, etc a list of files in the past when copying video files out of my photos directory into my videos directory for Plex to find but this is so much easier 🙂