Z!re
|
 |
« Reply #15 on: November 17, 2005, 09:53:45 AM » |
|
SUB RENAME (FILE1 AS STRING, FILE2 AS STRING) NAME FILE1, FILE2 END SUB :roll: #define RENAME(a,b) NAME a, b 
|
|
|
Logged
|
|
|
|
Moneo
|
 |
« Reply #16 on: November 17, 2005, 02:38:40 PM » |
|
..... You are using:
NAME FileName.txt, NewFileName
And not:
NAME FileName.txt AS NewFileName You guys keep forgetting Ratt's advice above about the AS. *****
|
|
|
Logged
|
|
|
|
Z!re
|
 |
« Reply #17 on: November 17, 2005, 02:41:12 PM » |
|
..... You are using:
NAME FileName.txt, NewFileName
And not:
NAME FileName.txt AS NewFileName You guys keep forgetting Ratt's advice above about the AS. ***** Nope.. In QB you had to use AS, in FB there's no AS Rattrap just has some english grammar problems, so his post is a bit hard to understand 
|
|
|
Logged
|
|
|
|
Rattrapmax6
|
 |
« Reply #18 on: November 17, 2005, 06:47:58 PM » |
|
Rattrap just has some english grammar problems, so his post is a bit hard to understand  :lol: And the sad part is, I'm native english.... XD Perhapse braking up the post was a bad idea, New version: If you are using: Name "Filename.txt" AS "NewFilename.txt" : then that's incorrect,. Acording to FBWiki it needs to be: Name "Filename.txt", "NewFilename.txt" :.. :wink: ~~~~~ Better? EDIT: Aye, I missed his code... nm
|
|
|
Logged
|
Kevin ( x.t.r.GRAPHICS) 
|
|
|
Moneo
|
 |
« Reply #19 on: November 17, 2005, 11:57:34 PM » |
|
i'm tryin to make a program that takes all files in a givin directory, then renames them all... giving them a number, and leaving there extension in tact.... any help would be most appreciated  After all the ammunition that you've been given, were you finally able to put together something that worked? *****
|
|
|
Logged
|
|
|
|
xteraco
|
 |
« Reply #20 on: November 18, 2005, 08:07:20 AM » |
|
to tell the truth, last thing i tried was stylin's last example, the one he said works...
i tried it, and what it did was it renamed a single file i guess, so when i looked in the output dir, all i saw was 1 file... 1.jpg or 0.jpg i dont remember... but thats all that was there
sinse then i havent really messed w/ it..lol, i'm thinkin bout workin on it a little today, because i'm trying to use it to put a bunch of pics on my webpage and organise them...
another thing i was gonna use it for is... . well, heres a strory
for a while i was usin linux cause my windows box crashed, and i used linux to backup my old data, the burning software i use in windows uses joilet burning format, wich keeps filenames looking the same when there on disk... well, the burner in linux didnt accept burning with the joliet burning format and only supported some iso FS burning .... so when i burned all my data with that format, i lost the names of most of my mp3's... and some of them are so rare, i cant find the names to em on the web
the name loooks like I___am_a.....mp3
it really sucks! so what i'm wanted to do is use the file renamer to rename my songs as well, i couldnt do it by hand cause were talkin about 400 or so songs
so in short, no i havent gotten it to work yet... and i'm probably gonna haggle w/ it a bit today and see what happens
|
|
|
Logged
|
url=http://www.random-seed.net]  [/url]
|
|
|
Moneo
|
 |
« Reply #21 on: November 18, 2005, 08:57:13 PM » |
|
Xteraco, I couldn't figure out how the DIR$ worked in FB, so I put together a solution (see below) that works in QB and should also work in FB. I added checking and validation of the what you called "filetype". I also made sure that this filetype exists in the source directory. I changed the output directory to just "output" instead of "output\\"., and I deleted the MKDIR of this directory which makes testing a pain. I was going to have the user provide the name of the output directory, but I had all kinds of trouble trying to validate it. So, I basically left it like you had it. I added an audit trail file called "auditfil" so you can review what files were renamed to what. I tested this version, so it should do what you originally intended. If not, I'll fix it for you. Regards......... defint a-z cls count = 0 dummy$ ="!!!dummy" outdir$="output"
getft: print "What type of file (file extension .xxx) should be used"; input filetype$ if instr(filetype$,".")<>1 or len(filetype$)<2 or len(filetype$)>4 then print "ERROR: invalid file extension. Must be a dot + 1-3 characters." goto getft end if
print print "Enter path of the directory where these files can be found"; input dirin$ bkslash$="\" 'Note: dirin$ will be null when specifying default directory, ' and dirin$ can be "\" when specifying root directory. if dirin$="" or dirin$="\" then bkslash$="" s$="DIR "+dirin$+bkslash$+"*"+filetype$+"/B>"+dummy$ shell s$
open dummy$ for input as #1 'Note: if above DIR did not find files, dummy$ file will be a zero-length-file, ' which will give an immediate EOF. if eof(1) then print "FATAL ERROR: no files with "+filetype$+" found on directory "+dirin$ GOTO ENDOFJOB end if
open "auditfil" for output as #2 do while not eof(1) line input #1,f$ count=count+1 s1$="COPY "+dirin$+bkslash$+f$+" "+outdir$+"\"+ltrim$(str$(count))+filetype$ s$=s1$+">nul" shell s$ print #2,s1$ loop
s$="DEL "+dirin$+bkslash$+"*"+filetype$ 'Delete original files shell s$
ENDOFJOB: close kill dummy$ system
*****
|
|
|
Logged
|
|
|
|
Z!re
|
 |
« Reply #22 on: November 19, 2005, 10:04:49 AM » |
|
DIR() mask$ = "*.*" t$ = DIR$( mask$ ) do while t$ <> "" print "File found: "+t$ t$ = DIR$() loop Enjoy..
|
|
|
Logged
|
|
|
|
Moneo
|
 |
« Reply #23 on: November 19, 2005, 04:31:29 PM » |
|
Xteraco,
I forgot to mention that for my program above you need to create (make) the directory "output" before the first time you run it. This output directory must be a subdirectory of the default directory. *****
|
|
|
Logged
|
|
|
|
Z!re
|
 |
« Reply #24 on: November 19, 2005, 10:28:54 PM » |
|
In FB, creating a dir can be achieved with: MKDIR() Also, MKDR never "fails" unless you specify FB to use error checking etc in the compiled file..
Basically, just stick a MKDIR() in there, and the program will always work, if the dir already exist or if it does not already exist..
|
|
|
Logged
|
|
|
|
Moneo
|
 |
« Reply #25 on: November 19, 2005, 11:14:28 PM » |
|
In FB, creating a dir can be achieved with: MKDIR() Also, MKDR never "fails" unless you specify FB to use error checking etc in the compiled file..
Basically, just stick a MKDIR() in there, and the program will always work, if the dir already exist or if it does not already exist.. Z!re, If I interpret what you say correctly, then I'm not convinced that MKDIR should never fail. 1) If the directory already exists, then it's a good idea not to fail. QB will fail. But there's no harm done if you don't fail. 2) If the directory name or path\directory is of invalid format or has invalid characters, then the MKDIR should fail, otherwise the program will think it now has that directory available. Another poor, off-the-cuff decision in FB. Xteraco, If you're using FB, then take Z!re's advice and stick in the MKDIR. Since I'm running QB, I can't do that. *****
|
|
|
Logged
|
|
|
|
DrV
|
 |
« Reply #26 on: November 19, 2005, 11:19:08 PM » |
|
MkDir() can fail; if it does fail, you are expected to handle this - either by using the traditional On Error Goto ... or by checking the return value of MkDir: if mkdir("C:\blah") = 0 then print "success" else print "failure" end if
|
|
|
Logged
|
|
|
|
Moneo
|
 |
« Reply #27 on: November 19, 2005, 11:34:57 PM » |
|
DrV,
Ah yes, that makes more sense. Thanks. *****
|
|
|
Logged
|
|
|
|
stylin
|
 |
« Reply #28 on: November 19, 2005, 11:44:15 PM » |
|
What's the return value for MkDir(...) ? Is it safe to use this, function some_function( directory as string ) as integer ... if( mkdir( directory ) ) then return -1 end if ... '' assume directory was created end function
or are there multiple error codes ?
|
|
|
Logged
|
stylin:
|
|
|
Z!re
|
 |
« Reply #29 on: November 20, 2005, 02:10:24 PM » |
|
If you dont check the return value, no harm done.. if you cant create the directory, either the medium is write protected, or the directory already exist.. However, I use mkdir alone, no error checking, and noone has reported any problems.. If people write protect the folder they install my programs too, they got worse problems than my program not working  (Such as being silly/stupid) 99% of the time when MKDIR() "fails" it "fails" because the directory already exist, and as such, it cant really be counted as a fail.. really.. In short, if you just want to creat a dir, and only care that the dir exist, dont bother to check if mkdir worked or not.. Problems could be write protection, out of diskspace or the dir already exist.. The last one is silly to fail on.. The first two will fail later if you try to create files, and checking for file integrity is something you should do, and which is easier to do.. (Even if mkdir succeeds there might not be any diskspace left to make the actuall files, etc) If you want to be really anal, you should FIRST list all dirs in the folder, if a dir does not exist, create it, check for all errors, verify integrity.. then move on.. Or, you could just create the dir and ignore any errors related to it, as 99% of the errors are caused by the dir already exists 
|
|
|
Logged
|
|
|
|
|