Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
51 user(s) are online (39 user(s) are browsing Forums)

Members: 1
Guests: 50

utri007, more...

Headlines

 
  Register To Post  

Is there an easy way to copy one file to a sequence?
Just popping in
Just popping in


See User information
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
Go to top
Re: Is there an easy way to copy one file to a sequence?
Amigans Defender
Amigans Defender


See User information
/* 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_" || /* can't remember how to add leading zeros off-hand */
  
address command 'copy ' src dest
end


Go to top
Re: Is there an easy way to copy one file to a sequence?
Just popping in
Just popping in


See User information
@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
Go to top
Re: Is there an easy way to copy one file to a sequence?
Amigans Defender
Amigans Defender


See User information
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(i3'0')


Go to top
Re: Is there an easy way to copy one file to a sequence?
Just can't stay away
Just can't stay away


See User information
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>
Go to top
Re: Is there an easy way to copy one file to a sequence?
Home away from home
Home away from home


See User information
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.copy2srcname"%s_%03ld" % (destname,n))


Call like

python script.py src dest number


Go to top
Re: Is there an easy way to copy one file to a sequence?
Just can't stay away
Just can't stay away


See User information
@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>
Go to top
Re: Is there an easy way to copy one file to a sequence?
Just popping in
Just popping in


See User information
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
Go to top
Re: Is there an easy way to copy one file to a sequence?
Just can't stay away
Just can't stay away


See User information
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>
Go to top
Re: Is there an easy way to copy one file to a sequence?
Amigans Defender
Amigans Defender


See User information
@interrogative

That works but using right() is neater

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2023 The XOOPS Project