• 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: check alias
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: check alias


  • Subject: Re: check alias
  • From: Rounak Jain <email@hidden>
  • Date: Tue, 29 Sep 2009 21:53:09 +0530


set theitems to {"some paths to files/folders"}

try
set ifolder to (last item of theitems as text)
-- Leopard:Users:whatever:Desktop:
set filestomove to items 1 thru -2 of theitems

You can’t get item -2 of a one-item list.

its actually like this
using terms from application "Quicksilver"
on open theitems 
set ifolder to (last item of theitems as text)
..................
but you won't understand it if you have never used Quicksilver. So I tried to simplify it.

How about just providing the portion that’s giving you the problem?

try
set thedecision to "completed"
thedupcheck as alias
tell me to activate
set thedisplay to display dialog "An archive with the name \"" & thesourcename & "\" already exists in the destination" buttons {"Replace", "Rename", "Cancel"} default button "Replace"
try
if button returned of thedisplay is "Replace" then
set qthesourceitem to quoted form of (POSIX path of thesourceitem)
set qthedupcheck to quoted form of (POSIX path of thedupcheck)
do shell script "rm -r " & qthedupcheck
set qifolder to quoted form of (POSIX path of ifolder)


set thecmd to "mv " & qthesourceitem & " " & qifolder



do shell script thecmd




end if
end try


try
if button returned of thedisplay is "Rename" then
repeat
set qthesourceitem to quoted form of (POSIX path of thesourceitem)


set thenewname to my getname(thesourcename)
set thenewcheck to ifolder & ":" & thenewname


set qthenewcheck to quoted form of (POSIX path of thenewcheck)


set qifolder to quoted form of (POSIX path of ifolder)
try
thenewcheck as alias
on error e
set thecmd to "mv " & qthesourceitem & " " & qthenewcheck
do shell script thecmd
set thecmd to "mv " & qthenewcheck & " " & qifolder


do shell script thecmd




exit repeat
end try
end repeat
end if
end try


on error e
--say 9
set thedecision to "proceed"
end try



--say 10
tell me to activate
display dialog thedecision
return thedecision


end dupcheck



on getname(thesourcename)
try
set AppleScript's text item delimiters to "."
set thenametext to text items 1 thru -2 of thesourcename
set thenameextension to last text item of thesourcename
set thenametext to thenametext as string
set AppleScript's text item delimiters to ""
on error e
--for folders
set thenametext to thesourcename
end try
tell me to activate
set thenewname to text returned of (display dialog "Enter the new name: (This dialog box will reappear if an item with the new name you specified also exists in the destination folder)" default answer thenametext)
try
set thenewname to thenewname & "." & thenameextension
on error e
--for folders
set thenewname to thenewname
end try
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: check alias (From: Rounak Jain <email@hidden>)
 >Re: check alias (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Re: Detecting when URL has been loaded in Safari???
  • Next by Date: Test
  • Previous by thread: Re: check alias
  • Next by thread: Please re-write my script
  • Index(es):
    • Date
    • Thread