{"action":"created","issue":{"url":"https://api.github.com/repos/jlegewie/zotfile/issues/197","labels_url":"https://api.github.com/repos/jlegewie/zotfile/issues/197/labels{/name}","comments_url":"https://api.github.com/repos/jlegewie/zotfile/issues/197/comments","events_url":"https://api.github.com/repos/jlegewie/zotfile/issues/197/events","html_url":"https://github.com/jlegewie/zotfile/issues/197","id":109290035,"number":197,"title":"Delete folder(s) if no last file is moved out","user":{"login":"Unode","id":122319,"avatar_url":"https://avatars.githubusercontent.com/u/122319?v=3","gravatar_id":"","url":"https://api.github.com/users/Unode","html_url":"https://github.com/Unode","followers_url":"https://api.github.com/users/Unode/followers","following_url":"https://api.github.com/users/Unode/following{/other_user}","gists_url":"https://api.github.com/users/Unode/gists{/gist_id}","starred_url":"https://api.github.com/users/Unode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Unode/subscriptions","organizations_url":"https://api.github.com/users/Unode/orgs","repos_url":"https://api.github.com/users/Unode/repos","events_url":"https://api.github.com/users/Unode/events{/privacy}","received_events_url":"https://api.github.com/users/Unode/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jlegewie/zotfile/labels/bug","name":"bug","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-01T12:34:32Z","updated_at":"2015-10-03T13:01:07Z","closed_at":null,"body":"I frequently store entries with corresponding PDF or other documents before assigning to a given collection. This means they stay in \"Unfiled items\" and will have a corresponding \"undefined/\" location on disk.\r\nLater on I reassign the entry to a given collection and hit \"Rename attachments\" to force the file to move to a new folder matching the new collection. This works fine however the folder hierarchy created under \"undefined/...\" is, after a while, left full of empty folders.\r\n\r\nCould zotfile remove these folders and any parent in the hierarchy when the last file is moved or removed out of it (i.e. when the folder first becomes empty)?"},"comment":{"url":"https://api.github.com/repos/jlegewie/zotfile/issues/comments/145246246","html_url":"https://github.com/jlegewie/zotfile/issues/197#issuecomment-145246246","issue_url":"https://api.github.com/repos/jlegewie/zotfile/issues/197","id":145246246,"user":{"login":"jlegewie","id":1292401,"avatar_url":"https://avatars.githubusercontent.com/u/1292401?v=3","gravatar_id":"","url":"https://api.github.com/users/jlegewie","html_url":"https://github.com/jlegewie","followers_url":"https://api.github.com/users/jlegewie/followers","following_url":"https://api.github.com/users/jlegewie/following{/other_user}","gists_url":"https://api.github.com/users/jlegewie/gists{/gist_id}","starred_url":"https://api.github.com/users/jlegewie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jlegewie/subscriptions","organizations_url":"https://api.github.com/users/jlegewie/orgs","repos_url":"https://api.github.com/users/jlegewie/repos","events_url":"https://api.github.com/users/jlegewie/events{/privacy}","received_events_url":"https://api.github.com/users/jlegewie/received_events","type":"User","site_admin":false},"created_at":"2015-10-03T13:01:07Z","updated_at":"2015-10-03T13:01:07Z","body":"For this particular issue, take a look at line 2921 in zotfile.js (see below). Now that I look at it, I think I never implemented the \"delete empty folder\" feature for renaming. I only did it for removing files from the tablet folder. So you would have to add something similar to the renaming function.\r\n\r\n```\r\n// remove subfolder if empty\r\nif(!folder.equals(this.createFile(this.prefs.getCharPref('tablet.dest_dir'))))\r\n    this.removeFile(folder);\r\n```"}}