Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bLiss

macrumors member
Original poster
Jun 14, 2005
95
1
usa
I'd like to copy the filename and the date created (basically, whatever my Finder's List View shows, which is minimal) so that I can paste it into a plain text document.

Is there an easy way to do this without a script? As it stands, when I copy and paste to the text document, I just get the filename with its extension.

Thanks.
 
You can open a Get Info window for the file, and double-click the Date Created to select it. Then you can just copy and paste it.

If you want the filename copied at the same time, there is no way to do that without a script.
 
Thanks for the reply, but Get Info doesn't seem to allow selecting or copying of anything. I wouldn't mind manually copying the date created if it were as easy as copying the filename somehow.
 
Ok, maybe it's time you revealed the OS you have.


And what OS is that? Doesn't work here. (see above for my OS)

I'm using Snow Leopard, and it works for me (don't try it on the "Created:" text, try it on the actual date).
 
I'm using Snow Leopard, and it works for me (don't try it on the "Created:" text, try it on the actual date).

Works perfectly fine for me with 10.6 as well.
 

Attachments

  • finder-copy-created.png
    finder-copy-created.png
    101.6 KB · Views: 471
I don't think Unix stores creation times, only modified times, in which case you can get via Terminal with:
Code:
ls -lt
 
I don't think Unix stores creation times, only modified times, in which case you can get via Terminal with:
Code:
ls -lt

For creation time,

Code:
 ls -lU

or

Code:
 ls -lUho

for more human-friendly output.
 
So this might be a naive question but isn't Finder referencing some particular part of the file's metadata for the Date Created, and if so, why can't ls output that? I used variations of the ls command to get the creation date, only to find the modification date no matter what, as angelwatt pointed out.
 
as angelwatt pointed out.

I'm actually getting mixed results. Depending on the app I use to edit the file, sometimes the created date gets changed to the new modified date. The -lU arguments were showing the creation date though. It simply wasn't obvious at first.
 
I know you didn't want a script, but this Applescript will copy the currently selected file in Finder's name and creation date. It just does name, a space, then the date. Not very fancy, but I wasn't sure how you wanted it formatted. The code can easily be modified to do what you want. Then you can add it to the script menu (see below) then you can access the script straight from Finder.

Code:
tell application "Finder"
	activate
	set _folder to POSIX path of ((folder of the front window) as alias)
	set _files to (get selection)
	set _file to item 1 of _files
	set _name to (name of _file)
	set _fp to _folder & _name
	set _date to do shell script "ls -lU " & quoted form of (_fp) & " | cut -d ' ' -f 9-11"
	set the clipboard to (_name & " " & _date)
end tell

Turn on Script Menu:
  1. Open AppleScript Editor (10.6), Script Editor (<10.6)
  2. Go to Preferences
  3. General tab, check box for show script menu
 
Code:
tell application "Finder"
	activate
	set _folder to POSIX path of ((folder of the front window) as alias)
	set _files to (get selection)
	set _file to item 1 of _files
	set _name to (name of _file)
	set _fp to _folder & _name
	set _date to do shell script "ls -lU " & quoted form of (_fp) & " | cut -d ' ' -f 9-11"
	set the clipboard to (_name & " " & _date)
end tell

Thank you for your help but it's only returning the name for me. In fact, in my terminal ls -lU doesn't work due to the U.
 
Thank you for your help but it's only returning the name for me. In fact, in my terminal ls -lU doesn't work due to the U.

Hmm, I wonder is that argument was added in Snow Leopard then. I don't have a Leopard machine handy to check right now, but if you enter the command "man ls" it will show you the help page and you can go down and see what arguments it does support. Hit q to quit out of the help.
 
I confirmed Leopard does not have the U argument for the ls command. I found an alternative way to do the AppleScript that doesn't require the ls command.

Code:
tell application "Finder"
	activate
	set _folder to POSIX path of ((folder of the front window) as alias)
	set _files to (get selection)
	set _file to item 1 of _files
	set _name to (name of _file)
	set _date to (creation date of _file)
	set {year:y, month:m, day:d, hours:h, minutes:m} to _date
	set the clipboard to (_name & " " & _date)
end tell
The _date variable will have a format like,
Code:
Monday, August 16, 2010 5:12:07 PM
which may not be what you want. I set some variables in the script that grabs the individual pieces such as year, month, etc. and assigns them to variables. You can then form whatever output string you want.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.