Qbasicnews.com
July 07, 2020, 12:35:08 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1] 2 3
  Print  
Author Topic: How To Copy And Rename Files Using Free Basic  (Read 7714 times)
speedlemon
I hold this place together
*****
Posts: 874



« on: July 20, 2005, 09:28:51 PM »

good evening ladies,
how can i copy a file to another directory and rename the exact same file. oh by the way, im working under the FB.
Logged
Sterling Christensen
Na_th_an
*****
Posts: 1328


« Reply #1 on: July 21, 2005, 12:46:48 AM »

Brilliant title! With only initials to work with, the phase "How To Copy And Rename Files Using Free Basic" somehow just sprang out at me - it's like telepathy!

Seriously though, I don't think it does a very good job of describing the topic when you have to read the message body to understand the title :roll:

I guess the simplest way would be to open both the source and destination, and then copy all the data. Or shell "copy blah blah2", if you don't care about portability.
Logged
speedlemon
I hold this place together
*****
Posts: 874



« Reply #2 on: July 21, 2005, 12:47:56 AM »

i dont care about portability.
i tried using shell copy but it didnt work.
but id like to use that method.
Logged
Sterling Christensen
Na_th_an
*****
Posts: 1328


« Reply #3 on: July 21, 2005, 12:55:27 AM »

Sorry no offense intended, ok?

Here's some code:
Code:
const bufferSize = 1024
old$ = "\old_folder\old_name.blah"
new$ = "\new_folder\new_name.blah"

' If new$ exists, delete it:
if len(dir$(new$)) then kill new$

open old$ for binary access read as #1
open new$ for binary access write as #2

' Assuming FB's input$ works like QB's, and assuming
' FB's put has no chr$(0) trouble, this should work:
do
   buffer$ = input$(bufferSize, #1)
   put #2, , buffer$
loop until len(buffer$) < bufferSize

close #1, #2


EDIT: Method #2 2.0 - the "I forgot filenames can have spaces" release:
Code:
#ifdef __FB_LINUX__
const copyCommand = "cp"
#else
const copyCommand = "copy"
#endif

shell copyCommand + " " + chr$(34) + old$ + chr$(34) + " " + chr$(34) + new$ + chr$(34)
Logged
speedlemon
I hold this place together
*****
Posts: 874



« Reply #4 on: July 21, 2005, 12:57:21 AM »

Quote from: "Sterling Christensen"
Sorry no offense intended, ok?

sorry for being rude :oops:
Logged
Sterling Christensen
Na_th_an
*****
Posts: 1328


« Reply #5 on: July 21, 2005, 01:07:25 AM »

It's ok.

I wish I could come up with something better. Both solutions I gave are ugly in their own ways. You'd think copying a file would be easier.
Logged
Dio
I hold this place together
*****
Posts: 874



« Reply #6 on: July 21, 2005, 02:58:10 AM »

strange, i got:

How To Catch A Rubber Fish Using Fake Bait.

i guess we all got our own interpretations/problems....
Logged

quote="whitetiger0990"]whitetiger is.. WHITE POWER!!! [/quote]
Here
Benedicto
New Member

Posts: 18


« Reply #7 on: July 21, 2005, 06:06:55 AM »

just shell using the command MOVE, put the new name as the second parameter
Code:
SHELL "MOVE  NEW.TXT  SUBDIR\THING\OLD.TXT"
Logged
whitetiger0990
__/--\__
*****
Posts: 2964



WWW
« Reply #8 on: July 21, 2005, 02:24:04 PM »

Quote from: "Benedicto"
just shell using the command MOVE, put the new name as the second parameter
Code:
SHELL "MOVE  NEW.TXT  SUBDIR\THING\OLD.TXT"

In linux it's "mv" just so you know.
Logged


[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
Z!re
*/-\*
*****
Posts: 4599


« Reply #9 on: July 21, 2005, 06:18:54 PM »

Ey!

Speedlemon?

You back!? Cheesy
Logged
arpgme
Member
*
Posts: 69


« Reply #10 on: July 22, 2005, 08:59:07 PM »

This doesn`t belong here.
Logged

~~~~~~~~~~~~~~~~~~~~~~~~~~

I love Quick Basic better then Python...

And Python is new.........

Oh yea catch ARPGME
Anonymous
Guest
« Reply #11 on: July 22, 2005, 09:31:29 PM »

you dont belong here. all in favor say AYE
Logged
whitetiger0990
__/--\__
*****
Posts: 2964



WWW
« Reply #12 on: July 22, 2005, 09:31:41 PM »

Quote from: "arpgme"
This doesn`t belong here.

*shrugs* meh the question was answered anyways =P
Logged


[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
Sumo Jo
Been there, done that
*****
Posts: 1244



WWW
« Reply #13 on: July 22, 2005, 09:34:08 PM »

Quote from: "arpgme"
This doesn`t belong here.


This forum although being intended for qb questions doesn't specifically say it.  

Also, with as many rules as your posts have been breaking, who are you to become a backseat mod?  Please leave the worries of where things  go to the moderators/admin.
Logged

url=http://fileanchor.com]FileAnchor[/url] - ImageAnchor - FBTK - QbasicNews - VPlanet - Various
Z!re
*/-\*
*****
Posts: 4599


« Reply #14 on: July 23, 2005, 06:42:10 AM »

arpgme, you just got SERVED!.. BOOOH YA!




*Ya, i know he's banned.. i just feelt like saying booh ya
Logged
Pages: [1] 2 3
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!