It's almost done...but I can't quite make it alone!

Hi

I have been refining my backup script with the help of the generous people here, however I can’t quite get the last part to work. I have labelled the line that isn’t working with --ISN’T WORKING!!. I want to begin listing a whole bunch of files that need to be duplicated to the recently created backup folder (targetFolder) but it just won’t work - no matter what I try. It always gives me a “Can set Finder…” error.

Here’s the script:

tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
to set targetFolder to “BackupTest-” & text 2 thru 3 & “/” & text 4 thru 5 & “/” & text -4 thru -1

set backupfolder to “Backup:Scripted Backups:”

tell application “Finder” to tell folder backupfolder
tell folder targetFolder to if exists then
tell me to display dialog "The backup for today has already been actioned. Backing up again will overwrite files. " & ¬
“Continue anyway?” default button 1 (* if the “Cancel” button is clicked, the script will stop here *)
delete
end if
make new folder at it with properties {name:targetFolder}
duplicate file “SystemX:test.doc” to targetFolder – ISN’T WORKING!!
end tell

Can anyone tell me what’s wrong?

Also, is there a clean way that I could make a list of files (within the script) to copy, and then just type a simple command that copies all the listed files to the targetFolder?

Thanks in advance…

Matthew

Model: iMac G5 2Ghz
AppleScript: 1.10.3
Browser: Safari 417.8
Operating System: Mac OS X (10.4)

tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
	to set targetFolder to "BackupTest-" & text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1

set backupfolder to "Macintosh HD:Users:UserName:Documents:Backup:Scripted Backups:" 

tell application "Finder" to tell folder backupfolder
	tell folder targetFolder to if exists then
		tell me to display dialog "The backup for today has already been actioned. Backing up again will overwrite files. " & ¬
			"Continue anyway?" default button 1 (* if the "Cancel" button is clicked, the script will stop here *)
		delete
	end if
	make new folder at it with properties {name:targetFolder}
	duplicate "Macintosh HD:Users:UserName:Documents:template_job_folder:type 3:su5:SystemX:test.doc" to folder targetFolder 
end tell


Make sure you have the full path of the files and folders.

Also Notice I took out “file” after the duplicate

Hi Mark

Cool!! It worked!! Here’s what I have:

tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
to set targetFolder to “BackupTest-” & text 2 thru 3 & “/” & text 4 thru 5 & “/” & text -4 thru -1

set backupfolder to “Backup:Scripted Backups:”

tell application “Finder” to tell folder backupfolder
tell folder targetFolder to if exists then
tell me to display dialog "The backup for today has already been actioned. Backing up again will overwrite files. " & ¬
“Continue anyway?” default button 1 (* if the “Cancel” button is clicked, the script will stop here *)
delete
end if
make new folder at it with properties {name:targetFolder}
duplicate “SystemX:test.doc” to folder targetFolder
end tell

Note that I have a partition called ‘Backup’ and one called ‘SystemX’.

Is there anyway to make a big list of files, and duplicate that list to the backup folder? I think this would be cleaner than lots of lines of 'duplicate… to ’

Regards

Matthew

tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
	to set targetFolder to "BackupTest-" & text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1

set backupfolder to "Macintosh HD:Users:UserName:Documents:Backup:Scripted Backups:"
set Sourcefolder to "Macintosh HD:Users:UserName:Documents:Backup:Source Folder"as alias
tell application "Finder" to tell folder backupfolder
	tell folder targetFolder to if exists then
		tell me to display dialog "The backup for today has already been actioned. Backing up again will overwrite files. " & ¬
			"Continue anyway?" default button 1 (* if the "Cancel" button is clicked, the script will stop here *)
		delete
	end if
	make new folder at it with properties {name:targetFolder}
	duplicate items of Sourcefolder to folder targetFolder 
end tell

This is if they are all coming from one folder.

Hi Mark

Unfortunately they’re not all coming from one folder…they’re from all over the show! Is there still a way?

Hi Mark

I had a few tries and doing this and could get it to work like this :

property filesToCopy : {alias “SystemX:test.doc”, alias “SystemX:testb.doc”, “SystemX:testfolder:”}

tell application “Finder”
duplicate every item of filesToCopy to desktop
end tell

However when I moved it into my script (below) it wouldn’t work.

tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
to set targetFolder to “BackupTest-” & text 2 thru 3 & “/” & text 4 thru 5 & “/” & text -4 thru -1

set backupfolder to “Backup:Scripted Backups:”
property filesToCopy : {alias “SystemX:test.doc”, alias “SystemX:testb.doc”, “SystemX:testfolder:”}

tell application “Finder” to tell folder backupfolder
tell folder targetFolder to if exists then
tell me to display dialog "The backup for today has already been actioned. Backing up again will overwrite files. " & ¬
“Continue anyway?” default button 1 (* if the “Cancel” button is clicked, the script will stop here *)
delete
end if
make new folder at it with properties {name:targetFolder}

duplicate every item of filesToCopy to targetFolder

end tell

Any idea why?

Regards

Matthew

How are you choosing them??

** just saw your last post.

Is that the only files are there lots more.

and again

How are you choosing them??

Hi Mark & Jacques

Thanks for your replies.

Mark - I have quite a few files that will be copied by this backup script. They are the same files every week. I select them by referring to them in the script.

Jacques - I will test your suggestions and let you know how I get on.

Matthew

Hi again

I’m almost there now. Here’s what I’ve got…and it works! The only thing is that I’d like to add the suffix “-COPY” and date (ie so the folder would be called “Documents-COPY 09/04/06” to the end of each file in the targetFolder. Any idea how to do this easily? I tried a few things, none of which worked out.



tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
	to set targetFolder to "BackupTest-" & text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1

set backupfolder to "Backup:Scripted Backups:"


--the block belows lists the files to be copied
property filesToCopy : {alias "SystemX:Users:Matt:Documents:", alias "SystemX:Users:Matt:Library:StickiesDatabase", alias "SystemX:Users:Matt:Library:Safari:", alias "SystemX:Users:Matt:Desktop:"}

--the block below lists the files that aren't to be copied. The defining of doNotCopyFilesA and doNotCopyFilesB is necessary as because the source location of files/folder is different, they must be returned to different places.
set doNotCopySourceA to "SystemX:Users:Matt:Documents:General:Miscellaneous:Photoshop_Notes:"
set doNotCopySourceB to "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:"

--the block below lists the files which AREN'T to be copied. 
property doNotCopyFilesA : {alias "SystemX:Users:Matt:Documents:General:Miscellaneous:Photoshop_Notes:Archives:"}
property doNotCopyFilesB : {alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:TT3Update.prc", alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:English Dictionary (XLarge).pdb", alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:WE 2003 Maps HiRes.prc", alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:WE 2003 Info.pdb"}
set tempStorageFolderA to "SystemX:Applications:Temporary Storage:A:"
set tempStorageFolderB to "SystemX:Applications:Temporary Storage:B:"

--the block below checks to see if the backup has already been perform. If not, a backup folder (with date attached) is created adn the script proceeds to move and copy files. If the backup has already been run, a dialog will give the option to cancel (ie stop the script) or delete the existing backup folder and create a new one.
tell application "Finder" to tell folder backupfolder
	tell folder targetFolder to if exists then
		tell me to display dialog "The backup for today has already been actioned. Backing up again will overwrite files. " & ¬
			"Continue anyway?" default button 1
		delete
	end if
	
	--the block below moves the files that aren't to be copied into a temporary storage location
	make new folder at it with properties {name:targetFolder}
	move every item of doNotCopyFilesA to tempStorageFolderA
	move every item of doNotCopyFilesB to tempStorageFolderB
	
	--the line below actually performs the copying of files listed in filesToCopy to targetFolder
	duplicate every item of filesToCopy to folder targetFolder --performs copying of files defined in filesToCopy line, to targetFolder
	
	--the block below moves the files that weren't copied from their temporary storage location, back to their respective original folders.
	move every item of doNotCopyFilesA to doNotCopySourceA -- Moves DoNotCopyFilesA back to doNotCopySourceA
	move every item of doNotCopyFilesB to doNotCopySourceB -- Moves DoNotCopyFilesB back to doNotCopySourceB
	
	
	
end tell




POSSIBLE IMPROVEMENTS:

I have a feeling that I could remove these two lines:


set tempStorageFolderA to "SystemX:Applications:Temporary Storage:A:"
set tempStorageFolderB to "SystemX:Applications:Temporary Storage:B:"

and have all files that aren’t to be copied dumped into one folder - however that’s just a small improvement. Or would this prevent them from being sorted back into their original folders…?

I tried to make this part cleaner:


property doNotCopyFilesA : {alias "SystemX:Users:Matt:Documents:General:Miscellaneous:Photoshop_Notes:"}

by doing something like :


property doNotCopyFilesA : {alias "Photoshop_Notes:" of doNotCopySourceA} 

But it wouldn’t work. If this could be done, it would clean up alot the jumble associated with doNotCopyFilesB as there are many long path names listed.

One last thing - how could I make the dialog clearer? My idea would be to have two buttons : “Continue & overwrite” and “Cancel & exit” . The latter would be the default button and would cause the script to stop in its tracks.

Once again, thanks for all the help.:slight_smile:

Matthew

PS - sorry for not inserting by scripts as compiled scripts before. I didn’t know how to do it.

tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
	to set targetFolder to "BackupTest-" & text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1

set backuplist to {}
set backupfolder to "Macintosh HD:Users:Username:Documents:Backup"

(* the Sourcefolder hold alias files of all the files you want to back up *)
set Sourcefolder to "Macintosh HD:Users:Username:Documents:2Backup" as alias

tell application "Finder" to tell folder backupfolder
	tell folder targetFolder to if exists then
		tell me to display dialog "The backup for today has already been actioned. Backing up again will overwrite files. " & ¬
			"Continue anyway?" default button 1 (* if the "Cancel" button is clicked, the script will stop here *)
		delete
	end if
	make new folder at it with properties {name:targetFolder}
	(* the original files of alias files are found here *)
	set this_item to the original item of items of Sourcefolder
	duplicate this_item to folder targetFolder
end tell


If you make the Sourcefolder a folder where you put aliases to the original files.
It would save the hassle you are having.

The script above looks in the Sourcefolder and copies the original files where ever they may actually be.
This way you can easily pick and choose what you want backed up without going back to edit the script.

tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
	to set targetFolder to "BackupTest-" & text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1
tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
	to set copyname to "-COPY_" & text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1

set backupfolder to "Macintosh HD:Users:Username:Documents:Backup"

(* the Sourcefolder hold alias files of all the files you want to back up *)
set Sourcefolder to "Macintosh HD:Users:Username:Documents:2Backup" as alias

global the_Final_name
tell application "Finder" to tell folder backupfolder
	tell folder targetFolder to if exists then
		tell me to display dialog "The backup for today has already been actioned. Backing up again will overwrite files. " & ¬
			"Continue anyway?" default button 1 (* if the "Cancel" button is clicked, the script will stop here *)
		delete
	end if
	make new folder at it with properties {name:targetFolder}
	
	
	set these_item to items of Sourcefolder
	
	repeat with i from 1 to number of items in these_item
		set this_item to item i of these_item
		(* the original files of alias files are found here *)
		set this_item to original item of this_item
		set dupe to duplicate this_item to folder targetFolder
		set this_Name to name of this_item
		my _set(this_Name)
		set duppe_ext to "." & name extension of dupe
		set the_Final_name to the_Final_name & copyname & duppe_ext as string
		set name of dupe to the_Final_name
	end repeat
end tell

on _set(this_Name)
	
	set AppleScript's text item delimiters to {"."}
	set line_start to text item -2 of this_Name
	set AppleScript's text item delimiters to ""
	set the_Final_name to line_start as string
end _set

This does the naming bit.

It works but it could be better. (nothing wrong with it but I like to get the duplicates done in one action) this uses repeats.

tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
   to set targetFolder to "BackupTest-" & text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1
tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
   to set copyname to "-COPY_" & text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1

set backupfolder to "Macintosh HD:Users:Username:Documents:Backup"

(* the Sourcefolder hold alias files of all the files you want to back up *)
set Sourcefolder to "Macintosh HD:Users:Username:Documents:2Backup" as alias

global the_Final_name
tell application "Finder" to tell folder backupfolder
	tell folder targetFolder to if exists then
		tell me to display dialog "The backup for today has already been actioned. Backing up again will overwrite files. " & ¬
			"Continue anyway?" default button 1 (* if the "Cancel" button is clicked, the script will stop here *)
		delete
	end if
	make new folder at it with properties {name:targetFolder}
	(* the original files of alias files are found here *)
	set this_item to the original item of items of Sourcefolder
	duplicate this_item to folder targetFolder
end tell
set backupfolder to backupfolder & ":" & targetFolder
tell application "Finder" to tell folder backupfolder
	
	set these_item to items of it
	
	repeat with i from 1 to number of items in these_item
		set this_item to item i of these_item as alias
		set this_Name to displayed name of this_item
		my _set(this_Name)
		set duppe_ext to "." & name extension of this_item
		set the_Final_name to the_Final_name & copyname & duppe_ext as string
		set name of this_item to the_Final_name
		
	end repeat
end tell
on _set(this_Name)
	
	set AppleScript's text item delimiters to {"."}
	set line_start to text item -2 of this_Name
	set AppleScript's text item delimiters to ""
	set the_Final_name to line_start as string
end _set

Ok this is better. does the name change after the duplicate.
Should be faster.

You can scrunch the first two lines into one like this:

tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string to tell (text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1) to set {targetFolder, copyname} to {"BackupTest-" & it, "-COPY_" & it}

-- To make the folders "generic" better to specify them this way:

set backupfolder to (path to documents as text) & "Backup"
-- the Sourcefolder hold alias files of all the files you want to back up
set Sourcefolder to (path to documents folder as text) & "2Backup" as alias

Hi

Adam - I couldn’t get your version to work. I suspect it’s because I don’t know how to write my paths as text…!! I tried a few things but gave up as it wouldn’t work.

Mark - I tried you latest script which worked well, although it returned an error when trying to rename a folder contained within the 2Backup folder. There were 3 files in the 2Backup folder (test.doc, testb.doc and a folder called testfodler). The .doc files were copied and renamed, however the folder was copied but not renamed. The error said : Can’t get text item -2 of “testfolder”

Any idea why it did this?

Matthew

PS - I really like the idea of the source folder containing aliases - it makes it so much easier for me to add/remove items to be backed up. I won’t need to play with the script, and therefore remove the risk of me screwing it up!!

I shouldn’t have butted in because I haven’t read your script carefully. This is what I thought you were trying to do:

-- pick a folder and then a file
set targetFolder to (choose folder) as alias
set copyname to (choose file) as alias
-- get their names
tell application "Finder"
	set tf to name of targetFolder -- mine is "testFolder"
	set cn to name of copyname -- mine is "toCopy.webloc"
end tell
-- append text and date to name
tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string to tell (text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1) to set {targetFolder, copyname} to {tf & "-BackupTest-" & it, cn & "-COPY_" & it}
-- get the new names in a list with item 1 the folder and item 2 the file.
set new to result
--> {"testFolder-BackupTest-10/04/2006", "toCopy.webloc-COPY_10/04/2006"}

If not, I apolgize for confusing the issue.

I should have realised you may stick folders in there. I will have a look. (I assume its also an Alias to the real folder)

EDIT

Ok this should take care of aliases of folders.

tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
	to set targetFolder to "BackupTest-" & text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1
tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
	to set copyname to "-COPY_" & text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1

set backupfolder to "Macintosh HD:Users:Username:Documents:Backup"

(* the Sourcefolder hold alias files of all the files you want to back up *)
set Sourcefolder to "Macintosh HD:Users:Username:Documents:2Backup" as alias

global the_Final_name, duppe_ext
tell application "Finder" to tell folder backupfolder
	tell folder targetFolder to if exists then
		tell me to display dialog "The backup for today has already been actioned. Backing up again will overwrite files. " & ¬
			"Continue anyway?" default button 1 (* if the "Cancel" button is clicked, the script will stop here *)
		delete
	end if
	make new folder at it with properties {name:targetFolder}
	(* the original files of alias files are found here *)
	set this_item to the original item of items of Sourcefolder
	duplicate this_item to folder targetFolder
end tell
set backupfolder to backupfolder & ":" & targetFolder
tell application "Finder" to tell folder backupfolder
	
	set these_item to items of it
	
	repeat with i from 1 to number of items in these_item
		set this_item to item i of these_item as alias
		set this_Name to displayed name of this_item
		set duppe_ext to "." & name extension of this_item
		my _set(this_Name, this_item)
		
		set the_Final_name to the_Final_name & copyname & duppe_ext as string
		set name of this_item to the_Final_name
		
	end repeat
end tell
on _set(this_Name, this_item)
	tell application "Finder"
		set AppleScript's text item delimiters to {"."}
		if class of item this_item is folder then
			set line_start to text item -1 of this_Name
			set duppe_ext to ""
		else
			
			set line_start to text item -2 of this_Name
		end if
		set AppleScript's text item delimiters to ""
		set the_Final_name to line_start as string
	end tell
	
end _set

Hi Mark

It’s almost there. Below is the full script as I have it - lots of extra junk but it does what I want. The only problem is that it fails to rename certain items. It renames all the folders (3), however there were 4 aliases of real files in the 2Backup folder. Only two were copied (strangely, the 2 that came from my SystemX (system disc) were copied. Niether was renamed. The error that it returned was: Can’t get text item -2 of “StickiesDatabase”.

The other two files (aliases of files sitting on the Desktop - which is one of the folders placed inside 2Backup) were not copied at all.

Just for your info, the four file aliases placed in 2Backup were:
StickiesDatabase
Picture 1
text to Sony
TV instructions.doc
(I chose various names, with/without extensions, with spaces etc to see if that was causing problems.)

The 3 folder aliases in 2Backup were:
Desktop
Documents
Safari
(these all backed up and changed names without problem)

Any idea what is going on?

Matthew

Here’s the script:




tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
	to set targetFolder to "Scripted Backup-" & text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1
tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string ¬
	to set copyname to " COPY-" & text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1

set backupfolder to "Backup:Scripted Backups"

--the block below defines the source folders of files that aren't to be copied. The defining of doNotCopySourceA and doNotCopySourceB is necessary because of the fact that there are multiple sources for the files that aren't to be copied, and they must therefore be returned to different places.
set doNotCopySourceA to "SystemX:Users:Matt:Documents:General:Miscellaneous:Photoshop Archives:"
set doNotCopySourceB to "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:"

--the block below lists the files which AREN'T to be copied. 
property doNotCopyFilesA : {alias "SystemX:Users:Matt:Documents:General:Miscellaneous:Photoshop Archives:Archives:"}
property doNotCopyFilesB : {alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:TT3Update.prc", alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:English Dictionary (XLarge).pdb", alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:WE 2003 Maps HiRes.prc", alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:WE 2003 Info.pdb"}
--the line below defines the location of the storage location where the ALL the doNotCopyFiles will be placed.
set tempStorageFolder to "SystemX:Applications:Temporary Storage:"


--** the line below defines the source folder, which holds aliases of files/folders that are to be backed up**
set Sourcefolder to "Backup:2Backup:" as alias

--the block below checks to see if the backup has already been perform.  If the backup has already been run, a dialog will give the option to cancel (ie stop the script) or delete the existing backup folder and create a new one.
global the_Final_name, duppe_ext
tell application "Finder" to tell folder backupfolder
	tell folder targetFolder to if exists then
		tell me to display dialog "Today's backup has already been completed. Are you sure you want to continue & overwrite the existing back up? " buttons {"Continue & overwrite", "Cancel"} default button 2 with icon stop giving up after 15 (* if the "Cancel" button is clicked, the script will stop here *)
		delete
	end if
	
	--the block below moves the files that aren't to be copied into a temporary storage location
	move every item of doNotCopyFilesA to tempStorageFolder
	move every item of doNotCopyFilesB to tempStorageFolder
	
	--the line below creates the new backup folder with date attached.
	make new folder at it with properties {name:targetFolder}
	
	--the line below defines the items to be copied - those that still remain in the source folder.
	set this_item to the original item of items of Sourcefolder
	
	--the block below does the actual copying
	with timeout of 5000 seconds
		duplicate this_item to folder targetFolder
	end timeout
	
	--the block below moves the files that weren't copied from their temporary storage location, back to their respective original folders.
	move every item of doNotCopyFilesA to doNotCopySourceA -- Moves DoNotCopyFilesA back to doNotCopySourceA
	move every item of doNotCopyFilesB to doNotCopySourceB -- Moves DoNotCopyFilesB back to doNotCopySourceB
end tell


--this block below does the renaming of copied files.
set backupfolder to backupfolder & ":" & targetFolder
tell application "Finder" to tell folder backupfolder
	
	set these_item to items of it
	
	repeat with i from 1 to number of items in these_item
		set this_item to item i of these_item as alias
		set this_Name to displayed name of this_item
		set duppe_ext to "." & name extension of this_item
		my _set(this_Name, this_item)
		
		set the_Final_name to (the_Final_name & duppe_ext as string) & copyname
		set name of this_item to the_Final_name
		
	end repeat
end tell
on _set(this_Name, this_item)
	tell application "Finder"
		set AppleScript's text item delimiters to {"."}
		if class of item this_item is folder then
			set line_start to text item -1 of this_Name
			set duppe_ext to ""
		else
			
			set line_start to text item -2 of this_Name
		end if
		set AppleScript's text item delimiters to ""
		set the_Final_name to line_start as string
	end tell
	
	
end _set





Hi Jacques

Thanks for taking the time to have a look at my script. From what I can tell, you have made some nice improvements. Unfortunately the script returned this error when I ran it :

Finder got an error. Can’t get original item of every alias file of alias “Backup:2Backup:”.

I tried a few things to make it work (eg removed word ‘alias’ from this line : set Sourcefolder to alias “Backup:2Backup:”) but it didn’t help.

Any ideas what is going wrong?

Regards

Matthew

Hi Jacques

I’m running OSX 10.4.5.
Script Editor is 2.1.1 (81) and AppleScript is 1.10.3

I tried the first line you suggested and it returned this error:

tell application “Finder”
get original item of every item of alias “Backup:2Backup:” whose kind = “Alias”
“Finder got an error: Can’t get original item of every item of alias "Backup:2Backup:" whose kind = "Alias".”

I tried the second line you suggested and it returned this error:

tell application “Finder”
get original item of every item of alias “Backup:2Backup:”
“Finder got an error: Can’t get original item of every item of alias "Backup:2Backup:".”

I have no idea what is going wrong…

Regards

Matthew

Model: iMac G5 2Ghz
AppleScript: 1.10.3
Browser: Safari 417.8
Operating System: Mac OS X (10.4)

Hi Jacques

Thanks for persisting on this one!

With this line in:


set original_items to the original item of items of Sourcefolder

It returns this error:
“Finder got an error: Can’t get original item of every item of alias "Backup:2Backup:".”

With is line in:


set original_items to the original item of alias files of Sourcefolder

It returns this error:
“Finder got an error: Can’t get original item of every alias file of alias "Backup:2Backup:".”

I wonder what is causing the problem?

Matthew

Just in case you need it again, here’s the entire script:



property doNotCopyFiles : {alias "SystemX:Users:Matt:Documents:General:Miscellaneous:Photoshop Archives:Archives:", alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:TT3Update.prc", alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:English Dictionary (XLarge).pdb", alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:WE 2003 Maps HiRes.prc", alias "SystemX:Users:Matt:Documents:Palm:Users:Matthew Adams:Backups:WE 2003 Info.pdb"}

tell (current date) to tell 100000000 + day * 1000000 + (its month) * 10000 + year as string to tell (text 2 thru 3 & "/" & text 4 thru 5 & "/" & text -4 thru -1) to set {targetFolder, copyname} to {"BackupTest-" & it, "-COPY_" & it}

set backupfolder to "Backup:Scripted Backups"
set Sourcefolder to alias "Backup:2Backup:"

tell application "Finder"
	set original_items to the original item of alias files of Sourcefolder
	tell folder backupfolder
		tell folder targetFolder to if exists then
			tell me to display dialog "Today's backup has already been completed. Are you sure you want to continue & overwrite the existing back up? " buttons {"Continue & overwrite", "Cancel"} default button 2 with icon stop giving up after 15
			delete
		end if
		set targetFolder to make new folder at it with properties {name:targetFolder}
	end tell
	
	repeat with i in original_items
		if i as alias is not in doNotCopyFiles then
			with timeout of 3000 seconds
				set this_item to duplicate i to targetFolder
			end timeout
			tell this_item
				set {this_Name, this_ext} to {name, name extension}
				if this_ext is not "" then
					set name to (text 1 thru -((count this_ext) + 2) of this_Name) & copyname & "." & this_ext
				else
					set name to this_Name & copyname
				end if
			end tell
		end if
	end repeat
end tell


Model: iMac G5 2Ghz
AppleScript: 1.10.3
Browser: Safari 417.8
Operating System: Mac OS X (10.4)