473,659 Members | 2,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to rename a filename in a system folder with VBA code

Dear reader,

I have a table with two fields, the fields are FileNameOld and FileNameNew.

Now I am looking for VBA code to search in a system folder for the
FileNameOld and change the filename to the FileNameNew.

I am thankful for any help.
Kind regards,
Simon
Oct 8 '06 #1
1 4080
Simon wrote:
Dear reader,

I have a table with two fields, the fields are FileNameOld and
FileNameNew.

Now I am looking for VBA code to search in a system folder for the
FileNameOld and change the filename to the FileNameNew.

I am thankful for any help.
Kind regards,
Simon
Dir("path to file") will tell you if the file exists. It will return the file
name if it does or return a zero length string "" if it does not.

The Name command can be used to change the name once you determine that the file
does exist.

Name "full path to old file name" As "full path to new file name"
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Oct 8 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4629
by: fanbanlo | last post by:
C:\MP3\001.txt -> 0.txt C:\MP3\01. ??? - ????(???).mp3 -> 1.mp3 Traceback (most recent call last): File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript exec codeObject in __main__.__dict__ File "C:\MP3\!RenameNum.py", line 40, in ? renameFiles(os.path.dirname(sys.argv))
17
2089
by: tom | last post by:
Hello, got a prob with renaming a file; still don't know where is the mistake. this is the code: <% '*************************************************************************** * file_orig=session("nome_file") file_copy=session("id_risp") & "_" & session("id_recl") 'path_copy=Server.Mappath("/document/" & file_copy & ".doc")
7
9469
by: Tom | last post by:
I'm having a problem using a path with spaces as a parameter to os.rename() in a program on WinXP. This works fine at the command line (where the folder "c:\aa bb" exists) > os.rename( "c\aa bb", "c:\cc dd" ); > But, I can't get it to work in my program, eg.
5
4452
by: Rothariger | last post by:
Hello.... i want to know if its posible to rename multiple files like windows does.. example: file zzzzzzz.doc file asdasd.doc file esfsefse.doc
8
1954
by: Merlin | last post by:
Ok.... I feel really dumb on this one, because I had previously figured it out, and now don't have a clue. I'm trying to get the user to input a new filename (via an integer variable) and have that variable passed to rename, so that the file can be named whatever the user specifies in the console window.... Currently using
3
5367
by: Yannick Benoit | last post by:
Hi guys. I have like hundreds of pictures in a folder and then I use this function to rename them all to a following number. but very often I noticed that some pictures get lost and I dont know where ? anyone can tell me whats wrong ? $dir = getcwd()."/dump/"; $dh = opendir($dir);
6
2527
by: shuaishuaiyes | last post by:
Hello everyone... I'm a Chinese student and my English is very poor...So excuse me if I make grammar mistake. I want to ask some questions about "rename". I'm a beginner, so my C ..... :) I want to rename a batch of files..Such as I want to rename"1.avi,2.avi" to "Prison BreakS1E1.avi,Prison BreakS1E2.avi" in the same folder..How can I do?
0
1393
by: aris1234 | last post by:
how to rename file name in DB..??? this my code, but this code only save image to folder, can't rename file in DB : <?php //Сheck that we have a file $folder = "../property/$spid"; if(!file_exists($folder))
1
1329
by: shapper | last post by:
Hello, I am moving file from a folder A to folder B using: System.IO.File.Move(path, newpath) I am not sure if this is the best way to do this but I also need to: 1. Rename the file before coping it (I want to keep the extension. I just want to rename the filename)
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2750
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.