I need to create a new folder in the current directory with the date and if the date folder already exisists then I need to and a B to the end.
For Example I want the script to create a new folder in current directory 06_30_11 and if that date folder exists then create one with the name 06_30_11 B and if that one exists create one 06_03_11 C and so on.
This is the current script i got from here that isn’t working for me.
tell application "Finder" to make new folder at desktop with properties {name:"Backup du " & (do shell script "date -n +%Y.%m.%d")}
Hi,
try this
set timeStamp to do shell script "date -n +%y.%m.%d"
set currentDirectory to path to desktop
set folderName to timeStamp
set indexLetter to 1
repeat
tell application "Finder" to set folderExists to exists folder folderName of currentDirectory
if folderExists then
set folderName to timeStamp & space & character id (65 + indexLetter)
set indexLetter to indexLetter + 1
else
tell application "Finder" to make new folder at currentDirectory with properties {name:folderName}
exit repeat
end if
end repeat
Awesome, just one thing, I need it to create the Folder in the Front most current window I have open.
no problem
set timeStamp to do shell script "date -n +%y.%m.%d"
try
tell application "Finder" to set currentDirectory to target of Finder window 1
on error
display dialog "there is no open Finder window"
return
end try
set folderName to timeStamp
set indexLetter to 1
repeat
tell application "Finder" to set folderExists to exists folder folderName of currentDirectory
if folderExists then
set folderName to timeStamp & space & character id (65 + indexLetter)
set indexLetter to indexLetter + 1
else
tell application "Finder" to make new folder at currentDirectory with properties {name:folderName}
exit repeat
end if
end repeat