Below is a script that I assembled from various sources. It works. I made it into an App and placed it into the Dock, so I just select the file and then click on the app in the dock.
OBJECTIVE:
To replace a file that occupies disk space with a file of the exact same name that does not occupy (significant) disk space.
CURRENT PROBLEM:
It’s one-click, one file at a time.
CURRENT REQUEST:
Does anyone know how to make this script perform this operation several thousand times within a given folder?
-- Gets current folder and sets it as a variable "currentDir"
tell application "Finder"
if exists Finder window 1 then
set currentDir to target of Finder window 1 as alias
else
set currentDir to desktop as alias
end if
end tell
log POSIX path of currentDir
-- Copies selected file's name to clipboard
try
tell application "Finder" to set theName to name of item 1 of (get selection)
set the clipboard to theName
end try
-- Moves selected file to Trash
tell application "Finder"
move (get selection) to trash
end tell
-- Creates a new file with the copied name
tell application "Finder" to make new file at currentDir with properties {name:theName, creator type:"8BIM", comment:"I am a blank file! Wow, pointless!"}
Yes, I know this sounds stupid, but I need all the files to be present for some other operation to work, but I don’t want to use up so many KB per file.