Apr 8th, 2002, 07:23 PM
#1
Thread Starter
Hyperactive Member
rename files
Is it possible to rename all the .jpg files in a folder... The new name should be continues, 1, 2, 3, 4...
ex: (how do I get the new name?)
old name new name
text001.jpg 1.jpg
text003.jpg 2.jpg
text007.jpg 3.jpg
text009.jpg 4.jpg
text015.jpg 5.jpg
text016.jpg 6.jpg
any ideas?
thanks
Apr 8th, 2002, 07:35 PM
#2
Use Name
What are all ur .jpg currently loaded in? An Array?
Apr 8th, 2002, 07:45 PM
#3
Thread Starter
Hyperactive Member
Bruce Fox: I don't know how to load the current file names in order...
Can you help?
thanks
Apr 8th, 2002, 07:47 PM
#4
PowerPoster
this is an exectuable that I made recently. It does just what you're asking. I don't remember what controls I used, but it should work if you have vb6.
No viruses.
Attached Files
Apr 8th, 2002, 07:51 PM
#5
PowerPoster
Here's the source code. It doesn't have a lot of error handling since I only made it for me, but I haven't had it crash on me either.
Attached Files
Apr 8th, 2002, 08:01 PM
#6
Something like:
VB Code:
Private Sub Form_Load()
Dim arr() As String
Dim sBuff As String
Dim i As Long
sBuff = Dir("C:\New\*.jpg")
Do
ReDim Preserve arr(i)
arr(i) = "C:\New\" & sBuff
sBuff = Dir
If sBuff = "" Then Exit Do
i = i + 1
Loop
For i = 0 To UBound(arr) 'Rename each file starting with 1
Name arr(i) As ("C:\New\" & i + 1 & ".jpg") 'Both paths MUST be the same
Next
End Sub
NB: Practive on backup file first.
Last edited by Bruce Fox; Apr 8th, 2002 at 08:19 PM .
Apr 8th, 2002, 08:07 PM
#7
Fanatic Member
hi,
i have one text file i need renaming. Can i simply do this using 1 line of code?
Thanks
Nick
Apr 8th, 2002, 08:08 PM
#8
PowerPoster
name oldfilename as newfilename
Apr 8th, 2002, 08:10 PM
#9
Fanatic Member
****....
it says that in the first reply!
sorry!
Apr 8th, 2002, 08:13 PM
#10
Opps,
Should be:
VB Code:
For i = 0 To UBound(arr) 'Rename each file starting with 1
Name arr(i) As ("C:\New\" & i + 1 & ".jpg") 'Both paths MUST be the same
Next
U can also get rid of that ReDim statement (I have already edited ubove)
Last edited by Bruce Fox; Apr 8th, 2002 at 08:22 PM .
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width