Hi
I put together these applescripts (by trawling what others had done online) which will hide the .bak files.
Credit is due to someone else for the bulk of the programming, I just modified the code.
I use Keyboard Maestro to trigger the scripts in the Finder when the project folder is in focus.
There are 2 scripts I use. One to hide/show the .bak, and one to hide/show the .csh files.
Works a treat for my OCD, except when there are unusual characters in the file or folder name, such as an apostrophe.
Took ages to get it working and I’m not convinced it’ll work on everyone’s mac, but do let me know if you have success though!
Hide .bak
-- Toggle visibility of files having a chosen extension type in a folder
-- Run script once to hide, and again to show
-- Also includes lines for setting all files visible, or all invisible.
-- BP 2012
--••••••••••••••••••••••••••••••••••••••
set targetFileExtension to ".bak" -- Set this to the extension you want to hide. ⬅🔲
--••••••••••••••••••••••••••••••••••••••
tell application "Finder" to set currentDir to (target of front Finder window) as text
-- Get the names of files in folder, hidden or not:
set targpath to quoted form of POSIX path of currentDir
set zed to do shell script "ls " & targpath -- bypassing the Finder
-- Massage shell script data into a proper list:
set oldtid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "
"
set tlst to every text item of zed -- every file in folder (except UNIX invis)
set AppleScript's text item delimiters to oldtid
-- Toggle each files hidden status
repeat with n from 1 to count of tlst
if item n of tlst contains targetFileExtension then
set targpath to "'" & POSIX path of currentDir & item n of tlst & "'"
do shell script "chflags hidden " & targpath
--do shell script "chflags nohidden " & targpath
-- Comment out the line above, and uncomment one of the lines below to set
-- the visible status of everything in a folder to the same value
--tell application "System Events" to set visible of disk item targpath to true
--tell application "System Events" to set visible of disk item targpath to false
end if
end repeat
return targpath
Hide .csh
-- Toggle visibility of files having a chosen extension type in a folder
-- Run script once to hide, and again to show
-- Also includes lines for setting all files visible, or all invisible.
-- BP 2012
--••••••••••••••••••••••••••••••••••••••
set targetFileExtension to ".csh" -- Set this to the extension you want to hide. ⬅🔲
--••••••••••••••••••••••••••••••••••••••
tell application "Finder" to set currentDir to (target of front Finder window) as text
-- Get the names of files in folder, hidden or not:
set targpath to quoted form of POSIX path of currentDir
set zed to do shell script "ls " & targpath -- bypassing the Finder
-- Massage shell script data into a proper list:
set oldtid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "
"
set tlst to every text item of zed -- every file in folder (except UNIX invis)
set AppleScript's text item delimiters to oldtid
-- Toggle each files hidden status
repeat with n from 1 to count of tlst
if item n of tlst contains targetFileExtension then
set targpath to "'" & POSIX path of currentDir & item n of tlst & "'"
do shell script "chflags hidden " & targpath
--do shell script "chflags nohidden " & targpath
-- Comment out the line above, and uncomment one of the lines below to set
-- the visible status of everything in a folder to the same value
--tell application "System Events" to set visible of disk item targpath to true
--tell application "System Events" to set visible of disk item targpath to false
end if
end repeat
return targpath