![]() |
Program To Make Multiple Copies Of A File
Hello everyone.
I have been trying to find a program or Apple script which will allow me to select a file, or even a group of files, and then make a certain number of copies of that file, or files, by typing a number into a desired quantity field. If the program would allow me to define the naming scheme for the newly-created files, that would be a real bonus. To give you an idea of why I need such a program, I am currently working with a few different graphic and video related apps to learn how to make simple movies and flash animations. Some of the images I use are hand-created in PhotoShop, but in order to have the right frame rate, I need to make many copies of each file. Doing this with command-D is pathetic and a time-waster, particularly when you have to create dozens or hundreds of copies of the same image. Not only that, but then I have to use a second program to rename the files in sequence. Anyway, that is the general idea. I have looked high and low on the web, but I have not been able to find such a program. Even a simple Apple script would suffice if it saves me the hassle of hitting command-D repeatedly. Any help would be appreciated. Thanks in advance! |
This isn't quite everything you want, but it seems to be a step or three better compared to your current situation. Have a look at the Duplicate Files to Folder script application.
You may feel differently, but it seems like it could save you a bit of hassle. You may want to create two folders somewhere convenient for putting it to use, I'm thinking something like one named "Input" and another named "Output." As a shortcoming, you will have to move a file to the Input folder 5 times to get five copies, but it will at least create the duplicates and number them sequentially. |
Also not what you've asked for, but you may want to read the information in this hint: How to increment trailing digits in copied files' names, http://www.macosxhints.com/article.p...90529194228820, in particular my remarks about the effect of option-dragging multiple files to the same folder.
|
Hello NaOH. I had a look at that Apple script. As you surmised, it isn't exactly what I am looking for, but thanks for the tip anyway. The script might come in handy for some other project, so I went ahead and downloaded it.
MacOSNoob, thanks for the tip, but I am still running Tiger 10.4.11 on a ten-year-old G4. I am slowly saving up now for a 24" 3 Ghz iMac, but it irks me that these faithful old G4's last 10 years, while I hear the iMacs only last maybe 5 years at best. CRT's may be big, hot and clunky, but like the CPU's of yesteryear, they were built to last. How unlike these new delicate Macs. It's just like the car industry. They make them so thin and light nowadays, they are like death traps on wheels. :) Alright...so I went off on a tangent. :P |
Quote:
Trevor |
Hello Trevor. Well, believe me; I would absolutely love to have a Mac Pro -- and I have considered it -- but the truth is that I am now retired, and living on a fixed income; and trying to save that much money for the CPU, plus the cost of the monitor, would literally take me years to accomplish. I have lost a G3 and a G4 during the past year or so, and am now forced to work on a ten-year-old 400 mhz G4 with a 17" Apple CRT Display that will soon kick the bucket. So, as you can see, time is a factor here.
|
Quote:
Likewise, Apple does have clearance items. That is, past models which were never sold. Again, this is another way to save money. You may feel better with this method because you can have a sense of how reliable a machine was rather than buying it in the middle of its life cycle and wondering how reliable it is. If you consider either of these options, note that Apple updates them frequently as their stock of items changes. So, if you're close to purchasing, check them often, especially the refurbished page which can change day to day. Apple Refurbished Macs Apple Clearance Macs: The links aren't working now, but you'll see them on the left side of the refurbished page. Also, you may want to look into used items through something like Craigslist if it's available in your area. Of course, in such a case you need to determine if you're comfortable with the seller, but you also want to be certain the seller will provide the original, black-colored discs which came with the computer. |
Hello again NaOH. Thanks for the helpful info. I am going to have to give those ideas a lot of thought. I am not too keen on purchasing a used/refurbished product. As you stated, you never really know what kind of condition it may truly be in, just like a used car. I think that I would rather exercise patience and get something brand new, so that I can be sure of its state from the start.
|
Just to give you some more perspective, OSXdude, all the refurbished items I bought from Apple looked and acted like new. The one exception was a small nick on my laptop. I don't care about something like that, but I understand if others feel differently. As I said before, all the refurbs I've bought have performed flawlessly. Perhaps ironically, the last Mac I bought new in 2001 needed a logic board replacement upon receipt of the item, though it is still running now.
The other resource to consider is Amazon. They often have items at reduced prices when Apple updates items. Unfortunately, such items are not always clearly marked and you may need to determine them by using Apple's product numbers. Assuming you're in the US, an added bonus to Amazon is that shipping is free and sales tax is not charged unless you are in Washington, North Dakota, Kansas, Kentucky, and New York. |
Coming back to the first of the questions . . .
An Automator workflow will repeatedly duplicate files in Leopard: 1. Get Selected Items 2. Duplicate Finder Items 3. Loop --Loop automatically / Stop after ___ times --Use the original input Save as a workflow. Then, to duplicate a file X times, launch the workflow, insert X in the "Stop after ___ times" line, click on the file you want to duplicate (to select it as input for the workflow), and press Automator's Run button. I don't know how to make Tiger's Automator do something similar. However, here's a bit of AppleScript that seems to accomplish the same end as the Leopard workflow: Code:
display dialog "How many times do you want the duplicator to run?" buttons {"Cancel","OK"} default button "OK" default answer "" |
Hello NaOH. One important factor I neglected to mention is that I don't live in the USA, although we are a US territory. As a result, while you can easily go to the online Apple store and purchase a brand new 24" 3.06 GHz. iMac for $2,199.00, and get free shipping to your doorstep, I can't. In fact, for years Apple has even refused to ship items to us dedicated Mac users here, not even software.
So, we are forced to use other options; the first being the local authorized Apple distributor which has a complete monopoly on the local Macintosh situation. I called them the other day, and they want $2,429.00 for the same iMac. If I want it delivered to my home -- which is about five miles away from the store -- they will charge me extra for that as well. In fact, they don't even have it in stock. I would have to wait additional weeks while they ordered it from Singapore. Moral of the story: You folks in the USA should be very thankful that you have it so easy when it comes to purchasing Apple Macintosh products. I've been a Mac user since 1990 BTW. |
According to the Amazon Web site, they do ship to the following US territories and protectorates:
American Samoa Guam Mariana Islands Marshall Islands Micronesia Palau Puerto Rico U.S. Virgin Islands If you're in one of those locations, you may want to take advantage of Amazon's good/fair prices. Plus, a quick look around their site suggests shipping charges when applied to orders going to these locations are reasonable. You may want to confirm the details by looking around here and over here. If you have any uncertainty, you may want to contact them. I've never interacted with Amazon customer service, but the little bit I've ever heard has been positive. |
MacOSNoob, thanks for the AppleScript. It's exactly what I needed. In fact, I can select multiple items in the Finder, and it will duplicate all of them simultaneously.
I've never used Automator, and don't even know how to. BTW, I am on a Tiger 10.4.11 machine. |
Here you go, OSXdude.
Open your Applications folder. Then open Automator. Automator basically has three columns. In the middle column, find these Actions which macosnoob mentioned. 1. Get Selected Items 2. Duplicate Finder Items 3. Loop Drag each (in that order) to the blank column on the right. You're simply taking pre-built actions and building a little application. For the Loop action, set the options how you want them, which macosnoob indicated as follows: --Loop automatically / Stop after ___ times --Use the original input The only thing you need to decide is how many times you want the loop to occur, which should be the same as the number of copies you'd like to make. You have multiple saving options. I'm not running my 10.4 machine right now, but these should be the same. If not, and you can't figure out the 10.4 equivalents, just give a shout. To save it as an application – meaning you could drag items to your Automator application to duplicate them – use the File menu to select Save As. Give it a name, choose a location, and set the File Format to Application. To save it as a contextual menu item – meaning you could right click the items you want to duplicate and select your Automator workflow that you just created – use the File menu to select Save. Give it a name and you should be good to go. For either of these methods, you may want to create multiple variations. Let's say you prefer the contextual menu item method. You may want to make numerous versions. One might be titled "3 Duplicates," and another might be titled "4 Duplicates." The difference between these versions would, obviously, be how many copies of the original file are made. |
MacOSNoob, just as a matter of clarification -- Amazon probably doesn't know any better -- Guam is a part of the Mariana Islands, while Palau is a part of the FSM, or Federated States of Micronesia.
Thanks for the Amazon info. I was just over there checking it out. The only problem is that I never do any shopping online. While this may surprise you, I have never owned a single credit card in my entire life, which means I have no debts. I have always believed in the approach "If you've got the cash, buy it; if you don't have the cash, be patient, save up, persevere, and then purchase the item when you do have the cash. I've purchased a few items on lay-away, a few decades ago, but even then, you don't get the item until it is paid-in-full. If the American people -- and the world -- would learn to live this way, instead of on borrowed time, and borrowed cash, we would all be a lot better off for it. This age of impatience and instant gratification is ruining us all. Well gee...I had to throw in a little politics. :) Thanks for the Automator help. I'll fiddle with...although I am already happy with the way that the AppleScript works. :) |
Quote:
To me, that sounds a lot better than paying high prices to a local reseller who may be artificially inflating prices. Of course, it's your money, so it's your choice. |
Well, I've just been looking at Automator in Tiger 10.4.11, and it appears that it lacks some of the actions that are in Leopard.
There are two Finder actions -- "Get Selected Finder Items" and "Get Specified Finder Items" -- which will work. In Tiger, there is no "Duplicate Finder Items" action; however, there is a "Copy Finder Items" which does the same thing. There are two options; one to replace the original items, and a second to write the new copies to a new location. The problem is that there is no "Loop" action in the long list of 230 actions. There are 27 actions specific to the Finder, but none contain the word "loop". For now, I will be happy with using the AppleScript mentioned previously. BTW, believe me; I don't rely upon our local authorized Apple distributor by choice. It's simply that there really aren't any other viable alternatives. Even if I did have a credit card, and went through a site like Amazon, after they tack on shipping charges for sending a 25 pound iMac to me, the price would undoubtedly be about the same as what I would pay here. The irony is that many American companies view our island as a foreign country, even though we are a US territory which uses the US dollar, the US postal system, the US telephone system, etc. We have soldiers who have died in Iraq and Afghanistan. We are a little piece of America. But none of that matters to these companies. By purposely choosing to view us as a foreign country -- even though we aren't -- they then charge us international shipping rates, instead of US domestic shipping rates. It's all about Big Business greed. The one consolation about buying through our local Apple distributor -- not a real Apple store -- is that they take the risk. If something arrives damaged, it's not my problem, it's their problem. I don't have to endure long distance phone calls, being placed on hold for half an hour, being told there is nothing that they can do, aggravation as I explain to some half-witted tech guy or some shipping dept. guy that the item arrived damaged, etc. The local Apple distributor has to deal with all of that, and I am assured a good product in pristine condition. Of course, if Apple would stop being so paranoid, and allow us to purchase directly from them, that would solve a lot of problems. |
Glad the script macosnoob provided will, at least partially, serve your needs.
Quote:
|
Quote:
Pic.jpg Pic copy.jpg Pic copy 2.jpg Pic copy 3.jpg Pic copy 4.jpg . . . I would imagine you must need everything renamed according to some uniform pattern, like this: Pic0.jpg Pic1.jpg Pic2.jpg Pic3.jpg Pic4.jpg . . . Something else? Automator, even under Tiger, has a Rename Finder Items > Replace Text action to make short work of getting from the first list to the second. (Think of it as a find/replace operation that works on the names of selected files. In the above, the action was set to replace " copy " with "", which changes all but the first two items, and then I changed those remaining two by hand.) More simply, Rename Finder Items > Make Sequential will both assign a new name and sequentially number all selected files, saving you the trouble of remembering to change those first two filenames. The latter workflow: 1. Get Selected Finder Items 2. Rename Finder Items --Make Sequential --Add number to [x] new name [insert base filename] --set numbering options as needed To use the workflow, select all the items in the folder of duplicated files, then click Automator's Run button. NaOH (post #14) explains ways of saving such a workflow for reuse. |
MacOSNoob, thanks for the additional tip regarding renaming items. It is much appreciated.
NaOH, over here where I am, there is also divided sentiment regarding our current relationship with the US mainland. Some want to maintain the status quo. Some want statehood. Some want to be totally independent. And there are a few other flavors in between. |
just to tweak out snoobies script a bit:
Code:
tell application "Finder" |
Hello TW, thanks for the improvements to the script. That is even better.
I have been playing with it even further, and made two duplicates of it, so that one script will append a space -- instead of an underscore -- and will precede the number with a zero. The second script does the same thing, except it precedes the number with two zeros. What I am trying to do now, is figure out how to tell the scripts when to, and when not to, add the leading zeros. In other words, with the 2-digit script, I want a zero to precede the first nine copies, so that we have 01 to 09. However, from 10 onward to 99, I don't want the zero appended, so that we have something like this: FileName 01 FileName 02 FileName 03 FileName 04 FileName 05 FileName 06 FileName 07 FileName 08 FileName 09 FileName 10 FileName 11 FileName 12 FileName 13 etc... FileName 20 FileName 21 FileName 22 FileName 23 etc... In the case of the 3-digit script, I want two zeros to precede the first nine copies, so that we have 001 to 009. However, from 10 onward to 99, I only want one zero appended, so that we have something like this: FileName 001 FileName 002 FileName 003 FileName 004 FileName 005 FileName 006 FileName 007 FileName 008 FileName 009 FileName 010 FileName 011 FileName 012 FileName 013 etc... FileName 020 FileName 021 FileName 022 FileName 023 etc... FileName 090 FileName 091 FileName 092 FileName 093 etc... You get it? I don't have a lot of experience with the AppleScript language, but I imagine that you need to use some kind of "if" and "else" statements, something like this with the 2-digit script: if i = 1 to 9 then FileName = & " 0" & i if i => 10 then FileName = & " " & i In the case of the 3-digit script, I imagine it would be something similar: if i = 1 to 9 then FileName = & " 00" & i if i => 10 then FileName = & " 0" & i Can you -- or someone else -- help me to refine this so that it will work? It would be great if all three scripts could be combined into one script, so that it would first ask me how many zeros to append -- 0, 1 or 2 -- and then do the necessary duplicating and renaming. 0 would result in: FileName 1 FileName 2 FileName 3 FileName 4 FileName 5 FileName 6 FileName 7 FileName 8 FileName 9 FileName 10 1 would result in: FileName 01 FileName 02 FileName 03 etc... FileName 10 FileName 11 FileName 12 FileName 13 etc... 2 would result in: FileName 001 FileName 002 FileName 003 etc... FileName 010 FileName 011 FileName 012 etc... FileName 990 FileName 991 FileName 992 FileName 993 etc... Thanks! This would be a very useful script to upload to places like VersionTracker. To my knowledge, there is nothing like this there now, unless you buy something like FileBuddy. |
This should do it for you:
Code:
// pad string s to length l |
Okay, exactly where would I insert that new code into the original code that you gave me earlier?
Is that new code going to cause the script to ask me how many, if any, zeros to pad the numbers with? Or are you saying that I need to make different scripts to get different results? Thanks again. |
Sorry, my goof. It was TW who gave me the earlier code. Are you saying that I should add your code somewhere to his code?
Thanks! |
you can use LV's zero padding subroutine, which will work, but I usually use this approach (replace the set name of theDupe... line with these two lines):
Code:
-- use -2 or two places, -3 for three places, etc.if you want the script to ask whether you want 2 or 3 (or more) digit padding, add this bit near the beginning of the script: Code:
display dialog "How many digits do you want to pad the file index?" buttons {"Cancel", "OK"} default button "OK" default answer "2"Code:
set idx to characters -the_digits thru -1 of ("00000" & i ) as text |
If you used my code example, you would simply add it to the end of the script then call it within the script where you need it. so using tw's example:
Code:
set name of theDupe to theFileName & " " & pad(i,2)This is called a subroutine or "function". It allows you to use similar code from various places without repeating the same code over and over. |
Okay...let me address TW first since he responded first.
Based on what you've said, and if I've understood you correctly, my entire script now looks like this: ---------- tell application "Finder" set theFiles to the selection end tell display dialog "How many times do you want the duplicator to run?" buttons {"Cancel", "OK"} default button "OK" default answer "" set the_loops to text returned of the result as number display dialog "How many digits do you want to pad the file index?" buttons {"Cancel", "OK"} default button "OK" default answer "2" set the_digits to text returned of the result as number tell application "Finder" repeat with thisFile in theFiles set theFileName to name of thisFile repeat with i from 1 to the_loops set theDupe to duplicate selection -- use -2 or two places, -3 for three places, etc. set idx to characters -the_digits thru -1 of ("00000" & i) as text set name of theDupe to theFileName & " " & idx end repeat end repeat end tell ---------- When I select a file called "test.txt", tell it to make 20 copies, and to pad with 1 zero, here is what I get: Test.txt Test.txt copy Test.txt 0 Test.txt 1 Test.txt 2 Test.txt 3 Test.txt 4 Test.txt 5 Test.txt 6 Test.txt 7 Test.txt 8 Test.txt 9 What I expected it to do was to place a zero before the 1 through 9 items, and then continue with 10 through 20, so that it looks like this: Test.txt Test.txt 01 Test.txt 02 Test.txt 03 Test.txt 04 Test.txt 05 Test.txt 06 Test.txt 07 Test.txt 08 Test.txt 09 Test.txt 10 Test.txt 11 Test.txt 12 Test.txt 13 etc... Okay...I figured it out. I have to select the default answer of 2 to get the above results. I thought I was just supposed to tell it how many zeros to add, which is why I said 1. I just tried padding with three, and it also worked fine. :) Las_Vegas, I'll try your method now and see what kind of results I get. It seems with your code though, that I will have to make different scripts, depending on how much padding I want to do, right? Well...let me see... Okay, maybe I am doing something wrong, Las_Vegas, but no matter where I try to stick that chunk of code, when I try to compile, I get the error "expected "end" but found "/"" and the first "/" is selected by the script editor. Also, can you add something to your code so that, similar to TW's code, it will prompt me for both how many copies, as well as how much padding to do? That way I won't have to have one script for double digits, and another for triple digits. Thanks! |
Okay Las_Vegas, I assumed that the "//" was actually a comment line, and not really a part of the code, so I removed it, and placed the rest of the code after the final "end tell" like this:
tell application "Finder" set theFiles to the selection end tell display dialog "How many times do you want the duplicator to run?" buttons {"Cancel", "OK"} default button "OK" default answer "" set the_loops to text returned of the result as number tell application "Finder" repeat with thisFile in theFiles set theFileName to name of thisFile repeat with i from 1 to the_loops set theDupe to duplicate selection set name of theDupe to theFileName & " " & pad(i, 2) end repeat end repeat end tell on pad(s, l) repeat while length of s < l set s to ("0" & s) end repeat return s end pad When I do that, the code does compile; however, when I select the same file -- test.txt -- and run the script, and tell it to make 20 copies, all it does is make one copy called "test copy.txt" and I get the error "Finder got an error: Can't continue pad". |
LV got confused and used javascript notation '//' for comments, when he should have used applescript notation '--'. I do that all the time myself; why applescript needed it's own funky comment style is beyond me... :rolleyes: just replace the // with --
|
Yes, I already figured out that was a small error on his part; but even when I replace // with -- and add that string back into the code, it obviously makes no difference. The Finder is still throwing me that same error "Can't continue pad".
|
Quote:
|
TW, I think that I'll stick with your modifications to the previous code, as it is working fine.
Las_Vegas' code is still throwing me an error even after I change it to "my pad". When I tell the modified script to make 20 copies, it just makes one copy called "test copy.txt", and then the script editor gives me the error "can't get length of 1" with the "1" highlighted in this string in the code: repeat while length of s < l I've got a script that now does what I want, thanks to help from several of you here, so maybe we should just leave it at that. Again, it would be a nice gesture if someone could create a custom icon for it, and then upload it as a free Applescript to VersionTracker, Mac Update, etc. I'm calling my personal copy "File Duplicator & Multi-Digit Renamer". :) |
Quote:
Quote:
plus it's such a dinky little single-purpose script... |
Now it's working properly. :)
So with this version of the script though, you would have to actually edit that number if you want to pad with a different amount of zeros, or else make several different versions of the script; correct? It may be a "dinky little single-purpose script", but you'd be surprised by how much people look for such little apps. I looked all over the web to find something like this, but couldn't find anything, which is how I ended up here asking about it...and now we have a script. :) Of course, you could make it less "dinky" by adding a few more features to it, such as, for example, the ability to completely change the name of the new files. Have the script prompt the user for a new name. You could also have the script prompt the user for a new location to save the copies. There's all kinds of little things you could do to spice it up a little, without investing a lot of time into it. Make it like a free mini-version of FileBuddy. :) Just a thought. BTW, I do have a few things on VersionTracker, and could stick it on my server, but I don't have my web server online all the time, since I am now down to using one ten-year-old computer. |
Oh, BTW, while FileBuddy can sequentially rename files, to my knowledge, it cannot actually duplicate and rename files. I wrote to the author of that program a few days ago about adding the duplication function to his program, and he has yet to respond. So as you can see, for the time being, at least, this "dinky" Applescript might be useful to some people. Also, if folks can get the function free -- via this script -- why would they even want to pay for it later if some developer does add it to their commercial program? :)
|
| All times are GMT -5. The time now is 09:18 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.