is there a way that i can do something when the script runs only for the first time of day.
ok, basically i want finder to make a folder, which i think i know how to do, with the name set to the date, but only when the script is run the first time in any given day.
So say if on monday i ran the script it would create a folder called monday and all the files that i work in will be moved there. Then on tuesday at 10pm i run the script and it makes a folder called tuesday and then all the files i work on will be placed there.
to get the move, i am just going to place the folder nameinto a textdocument and call that as a variable, so when the code first runs that txt doc will get chaneged with the new folder name
Would something like this work? I’m not 100% sure what you want since you mentioned both the date and day as folder names.
set day_ to weekday of (current date)
set target_ to "path:to:location:for:new:folders:"
tell application "Finder"
if exists folder (target_ & day_ & ":") then
-- it has already been created
else
make new folder at folder target_ with properties {name:day_}
end if
end tell
set day_ to weekday of (current date)
set target_ to "Shared G4 HD:Users:karrenmay:Desktop:temp:"
tell application "Finder"
if exists folder (target_ & day_ & ":") then
-- it has already been created
else
make new folder at folder target_ with properties {name:day_}
end if
end tell
It doesn’t work. It creates an untitled folder. It should creae a folder called thu, as its thursday now.
Also can i format the date to give me:
dd/mm/year
???
if so how please
Of course, don’t try to name a folder or file with a colon (“:”) in it, it’s reserved for path delimiters. Forward slash (“/”) should also be avoided I think but somehow the OS handles this better.
i have tried wht you said john, and here is my code now, it throws an error which i will also post:
try
set day_ to do shell script "date + %m-&d-%Y"
set target_ to "Jessica HD:Users:karrenm:Desktop:Pls Print Me:"
tell application "Finder"
if exists folder (target_ & day_ & ":") then
-- it has already been created
else
make new folder at folder target_ with properties {name:day_}
end if
end tell
on error theError
set the clipboard to theError
end try
The error that is passed:
sh: d-%Y: command not found
date: illegal time format
usage: date [-nu] [-r seconds] [+format]
date [[[[[cc]yy]mm]dd]hh]mm[.ss]
I’m guessing i did a typo or something but cant see it. Any ideas?
Mac OS X, just does a straight swap. Any path that uses “/” as path delimiter will allow the “:” as a character in any part of the path file name, and vice versa. When using a traditional Mac OS “:” delimited based path the OS will replace any “:” in the file or path name with a slash, and working the other way does the opposite. This has some interesting implications when converting paths manually from one format to the other, which is one of the reasons why using the POSIX file and POSIX path commands is much safer.
This can be easily verified using terminal. I had to read the developer docs on this v.carefully when having to pass windows paths in a Mac OS app that was being updated from Mac OS to Mac OS X.
“strftime” is in man3 which is not formatted by default to save space. There are 9 man files in /usr/share/man/ In order to use the other man files, you’ll need to format them by using the ‘catman’ command…
The OS may make a swap of the delimiter at some level but from the Finder or AppleScript, you cannot add a colon to a file or folder name but a slash is added without problem: