Who's Online
60 user(s) are online (
43 user(s) are browsing
Forums )
Members: 1
Guests: 59
samo79 ,
more...
Topic options
View mode
Newest First
Is there an easy way to copy one file to a sequence?
Posted on:
2013/10/25 16:23
#1
Just popping in
Joined: 2008/4/22 18:03Last Login
: 9/27 22:30
From Lawrenceburg, KY
Group:
Registered Users
Good day, I was wanting to copy an image, say image_, to image_001, image_002, image_003, etc. I could do it the long way, copying each individual file; however, I'd like to do it the easy way. Any suggestions?
Sold the SAM460ex lite... waiting for money for X5000 or A1222 and OS 4.2
Re: Is there an easy way to copy one file to a sequence?
Posted on:
2013/10/25 16:32
#2
Amigans Defender
Joined: 2006/11/17 22:40Last Login
: 11/23 21:04
From England
Group:
Registered Users Moderators
/* arexx script */
src = "image_" /* you can get this from the command line if that's better, using something like parse arg src */
do i = 1 to 100
dest = "image_" || i /* can't remember how to add leading zeros off-hand */
address command 'copy ' src dest
end
Re: Is there an easy way to copy one file to a sequence?
Posted on:
2013/10/25 17:59
#3
Just popping in
Joined: 2008/4/22 18:03Last Login
: 9/27 22:30
From Lawrenceburg, KY
Group:
Registered Users
@Chris Thank you. I was trying to figure out a way of making an AmigaDOS script, especially since I have very little ARexx skills. I really must relearn ARexx... or start learning Python. Thank you again, Royce
Sold the SAM460ex lite... waiting for money for X5000 or A1222 and OS 4.2
Re: Is there an easy way to copy one file to a sequence?
Posted on:
2013/10/25 18:24
#4
Amigans Defender
Joined: 2006/11/17 22:40Last Login
: 11/23 21:04
From England
Group:
Registered Users Moderators
ARexx is dead easy if you know BASIC, and it can do more complex string manipulation (although it's no Perl). AmigaDOS probably can do what you want but it'll be convoluted. Python I have no clue about.
If you want leading zeros, change the line I commented to this:
dest = "image_" || right ( i , 3 , '0' )
Re: Is there an easy way to copy one file to a sequence?
Posted on:
2013/10/25 19:04
#5
Just can't stay away
Joined: 2006/11/24 18:52Last Login
: 2021/9/26 20:59
From Gloucestershire, UK.
Group:
Registered Users
A DOS scrit would be:
. bra {
. ket }
. key filename , ext , copies
set count 0
lab loop
set count ` eval $count + 1 `
echo Creating { filename } $count .{ ext }
copy "{filename}" "{filename} $count .{ext}"
if $count EQ { copies }
unset count
quit
endif
skip loop back
Run it with:
Execute script image_ jpg 100
Edited by Severin on 2013/10/25 19:28:54 Edited by Severin on 2013/10/25 19:32:56
Amiga user since 1985 AOS4, A-EON, IBrowse & Alinea Betatester Ps. I hate the new amigans website. <shudder>
Re: Is there an easy way to copy one file to a sequence?
Posted on:
2013/10/25 19:15
#6
Home away from home
Joined: 2006/12/4 23:15Last Login
: 10/14 16:04
Group:
Registered Users
Python would be:
#!C:python
import sys
import shutil
srcname = sys . argv [ 1 ]
destname = sys . argv [ 2 ]
copies = int ( sys . argv [ 3 ])
for n in xrange ( 0 , copies ):
shutil . copy2 ( srcname , "%s_%03ld" % ( destname , n ))
Call like
python script.py src dest number
Re: Is there an easy way to copy one file to a sequence?
Posted on:
2013/10/25 19:16
#7
Just can't stay away
Joined: 2006/11/24 18:52Last Login
: 2021/9/26 20:59
From Gloucestershire, UK.
Group:
Registered Users
@Chris leading zeros is afaik impossibe in DOS scripts as the cut command is far too limited. I wrote basics left$ and right$ command equivalents for my personal scripts eg. set countstring `Right$ 00000000$count 4` copy "{filename}" "{filename}$countstring.{ext}
Amiga user since 1985 AOS4, A-EON, IBrowse & Alinea Betatester Ps. I hate the new amigans website. <shudder>
Re: Is there an easy way to copy one file to a sequence?
Posted on:
2013/10/25 19:27
#8
Just popping in
Joined: 2008/4/22 18:03Last Login
: 9/27 22:30
From Lawrenceburg, KY
Group:
Registered Users
I ended up modifying the script Chris made using If-then statement
If i < 100 | i > 9
then
dest = "image-0" || i
else
if i < 10
dest = "image-00" || i
else
dest = "image-" || i
Sold the SAM460ex lite... waiting for money for X5000 or A1222 and OS 4.2
Re: Is there an easy way to copy one file to a sequence?
Posted on:
2013/10/25 19:45
#9
Just can't stay away
Joined: 2006/11/24 18:52Last Login
: 2021/9/26 20:59
From Gloucestershire, UK.
Group:
Registered Users
sorted the padding problem using echo but for some reason the script wont work anymore...
. bra {
. ket }
. key filename , ext , pad , copies
set count 0
lab loop
set count ` eval $count + 1 `
set countstring ` echo 00000000 $count len {pad} `
echo Creating { filename } $countstring .{ ext }
copy "{filename}" "{filename} $countstring .{ext}"
if $count EQ { copies }
unset count
unset countstring
quit
endif
skip loop back
just gives me: EXECUTE: Invalid directive.
Amiga user since 1985 AOS4, A-EON, IBrowse & Alinea Betatester Ps. I hate the new amigans website. <shudder>
Re: Is there an easy way to copy one file to a sequence?
Posted on:
2013/10/25 20:19
#10
Amigans Defender
Joined: 2006/11/17 22:40Last Login
: 11/23 21:04
From England
Group:
Registered Users Moderators
@interrogative
That works but using right() is neater
Currently Active Users Viewing This Thread:
1
(
0 members
and 1 Anonymous Users
)