Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Remove Microsoft Word backups via AppleScript Apps
Annoying Word backups can be easily removed recursively from any top path with this handy AppleScript. It looks for files named Backup...doc, and a couple others that Word has up its sleeve. I'm happy to share, but if you use it, email me and let me know! Better yet, if you improve it, send me your changes (and/or post them here in the comments).

[robg adds: I think you'll only have these files if you've enabled the "Always create backup copy" in Word's Save preferences. I haven't tested the script, but I did look through it, and it seems to do what it claims. If you're going to use it, though, I'd suggest using it in the "move files" mode, just to make sure it only removes the backup files you want it to.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[4,789 views]  

Remove Microsoft Word backups via AppleScript | 2 comments | Create New Account
Click here to return to the 'Remove Microsoft Word backups via AppleScript' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Remove Microsoft Word backups via AppleScript
Authored by: Ganymede on Jan 28, '05 04:01:11PM
How timely! I've just been grappling with recursive procedures to handle tedious tasks. For the record, Rob, if you use MS Word, you should definitely enable "Always create backup copy." Word & Excel crash on me regularly, that backup has saved me many a time.

Robert, in regard to the comment in your script asking why global variables need to be passed to functions, the answer is they don't. You didn't make them global. To do so use either the "global" or "property" declarations; the latter is more convenient. Below is a quickie script illustrating them. From reading the Applescript Language Guide (pp. 311-323), it becomes obvious that scope of variables is a tricky business in AS.

Something that was not at all obvious, however, and which AFAICT is not stated out loud anywhere in the Guide, is that parameters to subroutines ("run handlers") do not reveal any modifications upon return from the routine, that is, they are always local to the subroutine. Apparently, if you want more than a single value returned from a handler, you'll have to do it in a list or other structure. Took me a while to overcome my disbelief... passing parameters by reference is such a fundamental core value, I never questioned that it wouldn't be so!

Anyway, thanks for your script - check out these tidbits...

global count1
global count2
property user_home : path to home folder as alias
set count1 to 0
set count2 to 0
set folder1 to "Documents"
copy my checkfolder(folder1) to listing
set msgtext to "The following list has " & (count1 as text) & ¬
	" folders and " & (count2 as text) & " files:" & return & listing
display dialog msgtext buttons {"OK"} default button 1

on checkfolder(theFolder)
	set fldrpath to (user_home & theFolder) as string
	set fldrlist to list folder fldrpath without invisibles
	set thelist to "Contents of folder " & (fldrpath as string) & return & return
	repeat with eachFile in fldrlist
		set this_item to (fldrpath & ":" & eachFile) as alias
		set this_info to info for this_item
		if folder of this_info is true then
			set thetype to " (Folder)"
			set count1 to count1 + 1
		else
			set thetype to " (File)"
			set count2 to count2 + 1
		end if
		set thelist to thelist & ((eachFile & thetype) as text) & return
	end repeat
end checkfolder


[ Reply to This | # ]
Remove Microsoft Word backups via AppleScript
Authored by: ramanboucher on Feb 28, '05 05:56:05PM

Thanks for the advice on globals...and glad to be of help on the recursive function.

Best,
Raman



[ Reply to This | # ]