• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Variable renaming and managing a folder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Variable renaming and managing a folder (From: Bernard Azancot <email@hidden>)

  • Prev by Date: Re: GUI scripting in QuarkXPress
  • Next by Date: Re: Minimizing non-Frontmost Windows
  • Previous by thread: Variable renaming and managing a folder
  • Next by thread: RE: Variable renaming and managing a folder
  • Index(es):
    • Date
    • Thread