|
#1
| ||||
| ||||
| [AppleScript] Duplicate files with timestamp
Here's a script I just wrote today. It duplicates the currently selected files in the Finder, and then puts a timestamp in the name of the duplicates (instead of the generic "copy"). The timestamp uses a long date format that is properly sortable as plain text in any program: YYYY-MM-DD hh-mm-ss For example, if you load the script with "MyFile.txt" selected at 2:15 PM, the duplicate will be named something like "MyFile 2008-03-16 14-15-01.txt". It works with any number of files and folders selected at once.
__________________ Mac mini — 1.25GHz G4, 1GB RAM — OS 10.5.8 Useful programs: Privoxy, Butler, ffmpegX, VLC, Perian, Tofu, Wcalc Last edited by Mikuro; March 16th, 2008 at 02:29 PM. Reason: Changed file format from ".script" (compiled) to ".applescript" (text) |
| The Following User Says Thank You to Mikuro For This Useful Post: | ||
gabiton (July 23rd, 2009) | ||
|
#2
| |||
| |||
|
Hi Mikuro Could be just what I am looking for, but as a script newbie before I do something horribly wrong can you describe how: a) to install / use it (applescript editor compile. Run each time one wants to rename a file?) and b) it works from a user point of view. Ideally I would love to be able to right-click a file (ctrl-click) and have a 'timestamp duplicate' option. |
|
#3
| ||||
| ||||
|
Hi iaeon. There are different ways you could install it. I like to use the Script menu. I decided to write a how-to on enabling and using the Script menu, and I just posted it here: Use the AppleScript menu In short, I have it set up so that I select the file I want to duplicate in the Finder, then choose my script from the Script menu. |
|
#4
| |||
| |||
|
Thanks Mikuro - tried it out and works fine. Your script duplicates files and timestamps just as you say. Only thing - it opens in the script editor and has to be manually run. I don't seem to be able to compile it to an .app so that it just runs when selected fom the scripts menu. I tried opening the .applescript file and doing a compile but that does not work, and I tried opening it in Textmate first and then pasting to the script editor. This approach generates an error on a compile. "Syntax Error - Expected expression but found unknown token". The character it is unhappy with is  |
|
#5
| ||||
| ||||
|
I see. I didn't realize the script menu wouldn't work with plain-text scripts (.applescript files). Do this to convert it: - Open the file in Script editor. - Choose File > Save As - Select "Script" as the File Format and save it. That will give you a .scpt file that should work. The reason I posted a .applescript file instead of a .scpt is that .scpts don't seem to work on different computers sometimes. Or try downloading this .scpt I made. Maybe it'll work. |
| The Following User Says Thank You to Mikuro For This Useful Post: | ||
iaeon (September 21st, 2008) | ||
|
#6
| |||
| |||
|
Thanks Mikuro, works fine now, and as I said above just what I have been looking for! - I should probably have figured that one out myself! Funny how when 'somebody available knows better' ones own thinking abilities don't wish to be stretched.
|
|
#7
| |||
| |||
|
Hi, I downloaded a copy of your duplicator script today. It works very well with highlighted files. As a new user to script editor (I am very asinine with computers), I have not been able to understand very much of the jargon presented in the tutorials. How do I create a script that duplicates itself a number of times? I want to prank a friend of mine- I'm not trying to create a virus. |
|
#8
| ||||
| ||||
|
You can get the location of the script file with "the path to me". Then you just need to tell the Finder to duplicate it. Code: tell application "Finder" repeat with i from 1 to 100 duplicate (the path to me) delay 1 end repeat end tell (Note: If you run this in Script Editor, it might duplicate the Script Editor application. Save your file as an application and run it from the Finder for best results.) |
![]() |
| Bookmarks |
| Tags |
| applescript, duplicate, finder, script, timestamp |
| Thread Tools | |
|
|