I already have script which save the email as text file on specific folder.
but that script overwrite the file if file is already existing. but my question is :
I need script which doesn’t overwrite the existing file but give an unique name (any random numbers can be added in filename) and save on specific folder.
tia
-pmhooda
Hi ![:slight_smile: :slight_smile:](/images/emoji/apple/slight_smile.png?v=12)
Here one small suggestion :
set TheFolder to "Disk:Users:Me:Documents:SaveMail:" --The path of your folder
set TheFolderList to (list folder TheFolder) --The name of every items in the folder
set {FileName, NewName, FileNumber} to {"MailBodyText", "", 0} --Variables
--A loop to test if the NewName is in TheFolder and change the it if true
repeat until (NewName is not in TheFolderList)
set NewName to FileName & FileNumber & ".txt"
set FileNumber to FileNumber + 1
end repeat
![:wink: :wink:](/images/emoji/apple/wink.png?v=12)
thanks for your reply.
I tried this script, but its not going inside the repeat loop (i am new in apple script so pls forgive me if i am doing some silly mistake)
My script is as following :
-------beginning of script------------
set TheFolder to “folder name:” --The path of your folder
set TheFolderList to (list folder TheFolder) --The name of every items in the folder
set {FileName, NewName, FileNumber} to {“EmailReport”, “”, 0} --Variables
display dialog "this returned by TheFolderList " & TheFolderList & “.”
–A loop to test if the NewName is in TheFolder and change the it if true
repeat until (NewName is not in TheFolderList)
set NewName to FileName & FileNumber & “.txt”
display dialog "this newname inside the repeat loop " & NewName & “.”
set FileNumber to FileNumber + 1
end repeat
display dialog "this name returned by repest loop " & NewName & “.”
---------end of script-----------
I never see this dialog box -
display dialog "this newname inside the repeat loop " & NewName & “.”
please let me know what is wrong here.
thanks in advance.
-pmhooda