need a move and delete selected files script...award offer!

Hello,
After loosing my time with automator,

The script start it-self when computer start-up.

1/ move all files from “folderA” to “folderC”
2/ move all files from “folderB” to “folderC”
3/ delete in “folderC” all files that are more then 30 days old
4/ delete in “folderC” all files that are less then 20Mb
5/ delete all files that are not video (.mov)
5/ empty trash
6/ wait 30 seconds
7/ move files from “folderC” to “folderA”

this script should work on Mac os X10.5 (apple script 2.0.1) and 10.6

all the best,

Thomas

Model: imac
AppleScript: last
Browser: Safari 531.22.7
Operating System: Mac OS X (10.6)

Hi,

assuming 5) affects also only files of folder C try this,
there might be a problem if files in folder A and folder B have the same name.
Adjust the paths in the property lines, save the script as application bundle and add it to login items


property folderA : "MacHD:Users:myUser:Desktop:folderA:"
property folderB : "MacHD:Users:myUser:Desktop:folderB:"
property folderC : "MacHD:Users:myUser:Desktop:folderC:"

tell application "Finder"
	move items of folder folderA to folder folderC
	move items of folder folderB to folder folderC
	delete (every file of folder folderC whose modification date is less than ((current date) - 30 * days))
	delete (every file of folder folderC whose size is less than (20 * (10 ^ 6)))
	delete (every file of folder folderC whose name extension is not "mov")
end tell
delay 30
tell application "Finder" to move items of folder folderC to folder folderA

great, Thanks!
I try it and tell you what!
regards
Thomas

I modified StefanK’s code for something I thought would be more efficient (no offense to StefanK) he is a great coder

no need for folder c just remove the crap you don’t want then only move files you want to keep


set dt to path to desktop
set folderA to "" & dt & "folderA:"
set folderB to "" & dt & "folderB:"

tell application "Finder"
	delete (files of folder folderA whose modification date is less than ((current date) - 30 * days) or size is less than (20 * (10 ^ 6)) or name extension is not "mov")
	delete (files of folder folderB whose modification date is less than ((current date) - 30 * days) or size is less than (20 * (10 ^ 6)) or name extension is not "mov")
	move items of folder folderB to folder folderA
end tell


thanks for your input Mc Grailm but I actually need this moving from A to C to A.
I have a folder action script that load media into my interactive program (Isadora) from folderA. But it work only if media are droped into it…
So I need this little moving around.

I tested it, added the :
tell application “Finder”
empty the trash

and it work,

all the best,

Thomas

Dear StefanK & mcgrailm,

I still have 2 little problems with the script:

  1. this line:
 delete (every file of folder folderC whose name extension is not "mov")

was ment to delete all the corrupted .mov filles produced by my interactive programe (10% of the filles are not well produced, have a .mov extention but are not reconized and played by quicktime).
But it does not work because they are .mov eventhaught they are not playable video (The finder does not show their icone as a film image for exemple).
Do you have an idea how to go around this problem?
I post an exemple of corruped fille on this adress: http://www.thomasisrael.be/temp/corruptedmovfile.mov

  1. The last move to FolderA is ment to activate a “folder action script” witch load all the movies placed in folderA into my interactive program. On OS X 10.5, ones a folder action script is activated, it stayes activated even after a computer reboot. On OS X 10.4 it seems to not memorize this activation of the Folder Action Script.

I tries a piece of script I found to activate a folder action script at start up :

 tell application "System Events"
    set enabled of (script "isadora-dropload" of folder action folderA) to true
  end tell

but it does not work…(error message: NSReceiverEvaluationScriptError: 4)
do you have an idea how to solve that?

thanks for your help, all the best,

Thomas

Hi,

try to check the dimensions of the track. If an error occurs then the file is corrupted


property folderA : "MacHD:Users:myUser:Desktop:folderA:"
property folderB : "MacHD:Users:myUser:Desktop:folderB:"
property folderC : "MacHD:Users:myUser:Desktop:folderC:"

tell application "Finder"
	move items of folder folderA to folder folderC
	move items of folder folderB to folder folderC
	delete (every file of folder folderC whose modification date is less than ((current date) - 30 * days))
	delete (every file of folder folderC whose size is less than (20 * (10 ^ 6)))
	repeat with oneFile in (get every file of folder folderC)
		if my checkQTFile(oneFile as text) is false then
			delete contents of oneFile
		end if
	end repeat
end tell
delay 30
tell application "Finder" to move items of folder folderC to folder folderA

on checkQTFile(filePath)
	tell application "System Events"
		set qFile to QuickTime file filePath
		try
			get 1st track of contents of q whose dimensions is not {0.0, 0.0}
			return true
		on error
			return false
		end try
	end tell
end checkQTFile

to enable the folder action script the reference folder action must be just the name of the folder, not the full path

hello stefan,

Unfortunately your script send ALL files to the trash!!!

about the folder action script, maybe I misunderstood your comment

Because to activate the folder action script of foldeA at start-up I tried:

property folderA : "imac 150:Users:thomas:Desktop:folderA:"

tell application "System Events"
	set enabled of (folder action folderA) to true
end tell

but it does not work…

sorry for this extra brainpain but if everything is not working, nothing is usable…

all the best,

Thomas

the name of your folder is “folderA”, that’s also the name of the folder action


property folderA : "imac 150:Users:thomas:Desktop:folderA:"

tell application "System Events"
	set enabled of (folder action "folderA") to true
end tell

sorry I did a mistake in the handler, replace q with qFile in this line


get 1st track of contents of qFile whose dimensions is not {0.0, 0.0}

When I move the files, I would like to choose “Keep Both” when the error says “Do you want to replace the files with the same name.” How do I do that?
Also, I want to delete the files in Folder A Whose first 6 letters of the name (digits) add up to more than 100000, then move the rest to another folder.
Here’s my script:

property folderA : “Macintosh HD:Users:fmserver:SCAN:”
property folderB : “2Tb Backup:ScanBackups:”
property folderC : “Macintosh HD:Users:fmserver:SCAN:Problems:”

tell application “Finder”
move items of folder folderA to folder folderB
end tell

Thanks for any help!