Rename a file without knowing file name (1 Viewer)

eshai

Registered User.
Local time
Today, 13:08
Joined
Jul 14, 2015
Messages
193
hi
i have a db that take a snapshot to "c:\img" with extension of "jpg"
there is only one file in the folder at a time
the file saved each time with a different name
how do i rename the file to "1.jpg"
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:08
Joined
Oct 29, 2018
Messages
21,537
Hi,

You can use the Dir() function to get the name of the file, so you can rename it.
 

June7

AWF VIP
Local time
Today, 02:08
Joined
Mar 9, 2014
Messages
5,492
This simple test worked for me:

Name "C:\yourfolderpath\" & Dir("C:\yourfolderpath\") AS "C:\yourfolderpath\test.jpg"

If you want to use part of the original name in the new name, will have to parse the file name returned by the Dir() function.
 

eshai

Registered User.
Local time
Today, 13:08
Joined
Jul 14, 2015
Messages
193
Hi,

You can use the Dir() function to get the name of the file, so you can rename it.

tnx
i know but my head is to busy that i can't go over the dir function :banghead:
need help writing the code
 

eshai

Registered User.
Local time
Today, 13:08
Joined
Jul 14, 2015
Messages
193
This simple test worked for me:

Name "C:\yourfolderpath" & Dir("C:\yourfolderpath") AS "C:\yourfolderpath\test.jpg"

If you want to use part of the original name in the new name, will have to parse the file name returned by the Dir() function.

thank you that work perfect
love you
 

theDBguy

I’m here to help
Staff member
Local time
Today, 03:08
Joined
Oct 29, 2018
Messages
21,537
Hi June7. Thanks for the assist.
 

Users who are viewing this thread

Top Bottom