Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Copy file + folder

Author
Message
Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 16th Dec 2003 00:04
Is there anyway that I could use the copy file command to (obviously) copy a file, but if that file was in a folder that I want to exist in another directory. WOW! That's compilicated. You probably don't understand that so I'll show you an example.

You have a file:
"c:\blaa\test.file"

You want to copy it to another directory:
"c:\folder"

The folder "blaa" doesn't exist in the folder "folder"
I want it so I could just type:

I want it to automaticly create the folder "blaa" and put "test.file" in it.

All help would be greatly appreciated!


IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Dec 2003 14:36
Something like this? (Untested, coz I'm at work)



For free Plug-ins, source and the DBPro Interface library for Visual C++ 6 and .NET
http://www.matrix1.demon.co.uk
Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 16th Dec 2003 22:09 Edited at: 16th Dec 2003 22:10
yeah, but I have folders inside folders and a hole lot of files that i need my program to copy.

[edit]I just thought of something, not sure if it will work[/edit]


Jaze
21
Years of Service
User Offline
Joined: 20th Nov 2003
Location: Connecticut, USA
Posted: 16th Dec 2003 22:36
Make a TEXT file with the files to move... make the core structure like IanM said and read each one from list.... wild card coping will be trick...e.g.: copy *.*

I haven't used the filecopy command in DBPro.. so I don't know if it uses buffer or stream code. If it seems really kludgy... slower than operating system (noticably) let me know via email... I'll bang out a plug in for ya with lightning fast BIG buffer copying... bottom line: TO FAST


-=/Jaze/=-
Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 16th Dec 2003 23:00
E-mail sent


Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 17th Dec 2003 02:14
Ianm's way wouldn't work becuase I have a ton of files and some dont need folders, and they have all different lengths, some need 1 folder made, some need 10. This is really frustrating!


Jaze
21
Years of Service
User Offline
Joined: 20th Nov 2003
Location: Connecticut, USA
Posted: 17th Dec 2003 02:24
Did you get my email? Did you see I wrote you the fast copy thing? Or where you looking for the WHOLE deal to be done via text file etc. I just supplied a tried and true filecopy with a pretty big buffer good for moving media quickly. You'll see...

Read the source file after you DL the ZIP. (See my profile if you want to check it out for web address)


-=/Jaze/=-
Jaze
21
Years of Service
User Offline
Joined: 20th Nov 2003
Location: Connecticut, USA
Posted: 17th Dec 2003 02:27 Edited at: 17th Dec 2003 02:29
You could just SHELL OUT and run a DOS command... called XCOPY32.EXE That SHOULD preserve long filenames and you can move a WHOLE TREE
A whole drive... empty directores... hidden files.... etc.

DOS.. good ole DOS hehe

If you really want NICE automated deal - grab a command line zip/unzip util - and just shell out and tell the ZIP util to do what you want. winZip (if you register) has a great cmdline util... lean and to the point... like the pkzip days but with a more reliable zip alg.... (No WINZIPFIX...cuz it don't break... PKZIPFIX.EXE Dumbest program I ever saw... Its the one patch you MUST reinstall frequently


-=/Jaze/=-
Dave J
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 17th Dec 2003 02:30 Edited at: 17th Dec 2003 02:34
Use the path:

"..NewFolder"

That will move up a directory and copy into the folder "NewFolder" in the parent directory.

Ie.



If you're in the "Blaa" directory, it becomes:




"Computers are useless they can only give you answers."
Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 17th Dec 2003 03:18
Hey, I've never thought of using DOS! It's a great idea
Thanks JAZE, but now I don't have to use your DLL (although it does go fast!)




Jaze
21
Years of Service
User Offline
Joined: 20th Nov 2003
Location: Connecticut, USA
Posted: 17th Dec 2003 04:05
Wow - outdid myself.. Shoulda recommended DOS first eh? hehe

I'm glad the code ran fast though - thanx for at least using it once hehe. The trick is those block reads and using a big buffer chunk chunk chunk...


-=/Jaze/=-
Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 17th Dec 2003 04:55
Well, I might work on another program that involves mass file copying so I could use your dll You should release it for everyone to benifit from


Jaze
21
Years of Service
User Offline
Joined: 20th Nov 2003
Location: Connecticut, USA
Posted: 17th Dec 2003 05:31
I did You just got FIRST Delivery...


-=/Jaze/=-
Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 17th Dec 2003 22:48
Oh, Well I've yet to get the xcopy thing to work


Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 17th Dec 2003 22:55
ARG! The xcopy doesn't like filenames with spaces. Does anyone know how to get around this?


Jaze
21
Years of Service
User Offline
Joined: 20th Nov 2003
Location: Connecticut, USA
Posted: 17th Dec 2003 22:57 Edited at: 17th Dec 2003 22:58
Then make a text file with your files by going to the TOP directory of...perhaps your media?

dir /s > myfilelist.txt

Then Use that as a base to make your "COPY THESE FILES LIST"

though: xcopy32 c:/sourcefiles/*.* c:/dest/*.* /s /e (reverse slashes in filename paths) is good
but you need to turn on other switches I THINK so user don't get asked anything. Plus you can redirect the output to a TEMP.TXT file for tracking problems.

Contact me before you use that copy dll in a FULL deal... you don't have to... I just might have a better version is all because I'm working on taking a ton of my code and putting in into a DLL that DOES have a string table so its a regular DBPRO plugin


-=/Jaze/=-
Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 17th Dec 2003 22:59
WOW! That was fast. lol. I'll try it


Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 17th Dec 2003 23:59
I did all that but it still doesn't work. Is there any substitute for a space in dos?


Dave J
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 18th Dec 2003 00:02
DOS Filenames don't have spaces and are limitied to 8 chars, ie:

Hello Test.txt

becomes

HELLOTES~1.txt


"Computers are useless they can only give you answers."
Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 18th Dec 2003 00:35 Edited at: 18th Dec 2003 01:14
what about an absolute path?


Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 18th Dec 2003 03:57 Edited at: 18th Dec 2003 03:58
How would I do


?? This is very frustrationg! }:{


Dave J
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 18th Dec 2003 04:55
Try:

xcopy C:/DOCUMENT~1/OWNER~1/MYDOCUME~1/FOLDER~1/FILE~1 C:/FOLDER~1/FILE~1

Mind you the ~1 becomes another number if you have more then one file with the same combination of letters, if you had 2 folders:

my documents
my documents backup

They would be, respectively:

MYDOCUME~1
MYDOCUME~2

Or at least that's what I remember from my DOS days lol.


"Computers are useless they can only give you answers."
Jaze
21
Years of Service
User Offline
Joined: 20th Nov 2003
Location: Connecticut, USA
Posted: 18th Dec 2003 11:12
try quotes


-=/Jaze/=-
Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 18th Dec 2003 22:53
Quotes work.


Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 18th Dec 2003 23:32
I've had another change of plans. I will uses Jaze's copy utility but use xcopy just for the directories.


Jaze
21
Years of Service
User Offline
Joined: 20th Nov 2003
Location: Connecticut, USA
Posted: 19th Dec 2003 01:02
Cool that DLL seems solid.

(Now if I could get the one I'm currently working on that clean-n-stable)


Glad to Help

BTW - THERE is another "stupid" but "stable" (not clean) way using something very old - batch file! (I used to have this one book was CRAZY with strange DOS things beyond typical unix-like redirection tricks! I mean... if you know how - (I never mastered it) you really can do a lot with a batch file... and the POINT (I babble) I was getting to was sometimes making a batch file from within your program... or search-n-replace a template can be a good way to (either via program or parameters passed to batch file and putting some logic in it.)

I made a fast copy DLL that does the same deal on any 32bit platform but depending on if the OS in question DEFAULTS to BLOCK-READS (vs. buffer streams ... have small rw buffers usu.)it assures the "Fast way" however the OS is designed all around copying files etc. So even though I used sizable buffers... the OS may do same thing with less steps or some "black magic" storage tricks that could work even faster.

Sounds like you are making progress - and now you know some old DOS commands that have been upgraded to 32fat system... THOUGH some have not SO test first




-=/Jaze/=-
Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 19th Dec 2003 01:10
ARG! Your dll now just copies one file per program execution! WHY! My files exist!
Once it gets to the dll call the program exits...JUST exits. Nothing.
THIS IS A LOT HARDER THAN I THOUGHT IT WOULD BE (the project in general)
Can I have this new DLL?


Jaze
21
Years of Service
User Offline
Joined: 20th Nov 2003
Location: Connecticut, USA
Posted: 19th Dec 2003 01:27 Edited at: 19th Dec 2003 01:30
Hmm... that is REAL BAD news. (I've been banging my head on that same error myself and been talking with others on this site about it)

I suspect perhaps...sadly... the freepascal DLL linker isn't as good as their EXE stuff. It doesn't mangle the function names, it works PERFECT or crashes - I can't figure out if its DBPRo, Freepascal, or whatever because I don't have a problem with other dll's I've done. Even not calling from freepascal.... FLUKE? I just don't know... I haven't given up though. I apologize - your test and mine worked fine RIGHT? Then as you add more DB CODE and stuff... now it just doesn't work!!!!

I don't want to point fingers cuz I don't have every "piece" (the GORG resource compiler, the FPC compiler, the DBPro compiler....

All I know is that those functions in these DLL's I'm doing ARE running EVERYDAY, every minute, second on www.wimbleoffice.com CGI code (not script...I made true EXE's to handle each web request, hand made web templates... some borrowed (with permission) pull down menu osurce I wrote an editor for... very lean - fast system - not fastest connection.... not a super WEB server either...its a desktop.

THAT is WHY I would DARE to write a dll for a lang I JUST started! I am frustated also... but I just want to make some real useful tools available I already know work.... leverage a year and a half of development/test/improving a single codebase API.

Reusuable doesn't mean LOOK the same either - many seem to think reusuable code means your programs all look the same. I say - depends what and how you reuse. If the source code all looks similiar...same style...familiar function names etc.... I'm all for it... if all your work looks cookie cut - then... well.... its probably my gfx abilities - and not the code's fault.


-=/Jaze/=-
Wik
22
Years of Service
User Offline
Joined: 21st May 2003
Location: CT, United States
Posted: 19th Dec 2003 02:07
I ran the test program that came with it and it copied the file but still exeited without printing the stuff of susspending for key(ing)


Login to post a reply

Server time is: 2025-06-17 06:11:32
Your offset time is: 2025-06-17 06:11:32