{"id":738,"date":"2018-07-12T16:02:02","date_gmt":"2018-07-12T23:02:02","guid":{"rendered":"http:\/\/10.0.1.201\/?p=738"},"modified":"2018-07-12T16:02:02","modified_gmt":"2018-07-12T23:02:02","slug":"walk-down-a-directory-to-label-and-reveal-zero-byte-files","status":"publish","type":"post","link":"https:\/\/strawhousepig.net\/wordpress\/2018\/07\/12\/walk-down-a-directory-to-label-and-reveal-zero-byte-files\/","title":{"rendered":"Walk down a directory to label (and reveal) zero byte files"},"content":{"rendered":"<p><strong>_count<\/strong> is not working and I&#8217;m not sure why. :\/<\/p>\n<p>The <code>walkFolder()<\/code> function is recursive, so be careful where you choose to run this. Made to help identify corrupt old archives that have been copied (and copied) from Mac to WINDOWS to CDs and back.<\/p>\n<p><code>on walkFolder(f, _count)<br \/>\n\tlist folder f<br \/>\n\trepeat with i in the result<br \/>\n\t\tset _item to (alias (f & i))<br \/>\n\t\tif folder of (info for _item) then<br \/>\n\t\t\twalkFolder(f & i & \":\", _count)<br \/>\n\t\telse<br \/>\n\t\t\tif first character of i is not \".\" then<br \/>\n\t\t\t\tif size of (info for _item) is 0 then<br \/>\n\t\t\t\t\ttell application \"Finder\"<br \/>\n\t\t\t\t\t\tset label index of _item to 7 -- Gray. Perhaps adding a spotlight comment would be better...<br \/>\n\t\t\t\t\treveal _item -- Comment this out if you expect a lot of results.<br \/>\n\t\t\t\t\tend tell<br \/>\n\t\t\t\t\tset _count to _count + 1<br \/>\n\t\t\t\tend if<br \/>\n\t\t\tend if<br \/>\n\t\tend if<br \/>\n\tend repeat<br \/>\n\treturn _count<br \/>\nend walkFolder<\/p>\n<p>on run {}<br \/>\n\tset _count to 0<br \/>\n\ttry<br \/>\n\t\ttell application \"Finder\" to set cwd to folder of window 1 as alias<br \/>\n\ton error<br \/>\n\t\tset cwd to path to desktop folder<br \/>\n\tend try<br \/>\n\tset theFolder to (choose folder \"Select a folder to list:\" default location cwd) as string<br \/>\n\tmy walkFolder(theFolder, _count)<br \/>\n\tdisplay dialog (_count as text) & \" files found to be 0 bytes\" giving up after 600<br \/>\nend run<\/code><\/p>\n<p>Apologies for formatting errors as I&#8217;m editing this post on Safari from OS X 10.5 which doesn&#8217;t work well with WordPress&#8217; auto-drafting.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>_count is not working and I&#8217;m not sure why. :\/ The walkFolder() function is recursive, so be careful where you choose to run this. Made to help identify corrupt old archives that have been copied (and copied) from Mac to WINDOWS to CDs and back. on walkFolder(f, _count) list folder f repeat with i in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[10,28],"class_list":["post-738","post","type-post","status-publish","format-standard","hentry","category-code","tag-applescript-2","tag-os-x"],"_links":{"self":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/738","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/comments?post=738"}],"version-history":[{"count":0,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/posts\/738\/revisions"}],"wp:attachment":[{"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/media?parent=738"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/categories?post=738"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/strawhousepig.net\/wordpress\/wp-json\/wp\/v2\/tags?post=738"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}