Re: Variable renaming and managing a folder
Re: Variable renaming and managing a folder
- Subject: Re: Variable renaming and managing a folder
- From: Graff <email@hidden>
- Date: Sat, 22 May 2004 09:55:27 -0400
Here's an example of how to do this:
----
set theDate to current date
set theName to (short date string of theDate) -- only in AS 1.9.2 and
higher
-- set the last part of next line to the path where the new folder will
be
set thePath to (((path to startup disk) as text) &
"Volumes:volname:rest:of:path:")
tell application "Finder"
if (folder (thePath & theName) exists) then
delete folder (thePath & theName)
-- comment out the next line to automatically empty the trash
-- empty trash
end if
make new folder at folder thePath with properties {name:theName}
-- do backup stuff here
end tell
----
This script requires AppleScript 1.9.2 and higher because of the "short
date string":
<
http://www.apple.com/applescript/releasenotes/192OSX.html>
You can get around that by building your own date string and changing
the second line to set theName to that date string.
- Ken
On May 22, 2004, at 7:18 AM, Bernard Azancot wrote:
Hello !
My problem is simple but irritating newbie problem.
I backup files from an "A" drive to a "B" drive in a folder "X".
This folder is renamed according to the backup variable date reference.
Actually the script is OK, but it stops when it encounters a folder
with the same name as the day backup folder ("X" renamed) in the "B"
drive (backup already performed the same day).
I want to keep only one backup folder a day. So, when a folder with
the same name already exists in drive "B", I would like to
replace/delete it.
---
set MyFolder to folder "X"
set name of MyFolder to todaysDate as text
---
"X" --> "mm-dd-yyyy BU"
No problem of course to do it with the "X" folder *before* it has been
renamed, but I cannot figure how to do it with the new folder variable
name.
Deleting MyFolder deletes the new "X" folder, not the previous backup
folder.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.