UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Command To Rename Files In Folder, 2013    
 
   
bakersburg9
post Jul 22 2019, 10:48 AM
Post#1



Posts: 5,573
Joined: 2-November 04
From: Downey, CA


Is there a command / script to rename all files in a folder ?

Say my files were like:

Smith, John 2019-17-18
Brown, Ray 2019-17-18

and I wanted to change them, say, to

Smith_John_July_18
Brown_Ray_July_18

Or would it be easier or just as fast to write a macro to do basically the same thing ?

Thanks in advance,
Steve
Go to the top of the page
 
theDBguy
post Jul 22 2019, 10:50 AM
Post#2


Access Wiki and Forums Moderator
Posts: 76,577
Joined: 19-June 07
From: SunnySandyEggo


Hi Steve. Not sure about a command but you can always use a script to do it. For example, you could try using batch file, command script, or PowerShell script.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
bakersburg9
post Jul 22 2019, 11:52 AM
Post#3



Posts: 5,573
Joined: 2-November 04
From: Downey, CA


Thanks! Do you have an example of a batch file ? I could tweak it

thanks for chiming in !

Steve
Go to the top of the page
 
theDBguy
post Jul 22 2019, 12:02 PM
Post#4


Access Wiki and Forums Moderator
Posts: 76,577
Joined: 19-June 07
From: SunnySandyEggo


Hi Steve. I don't, so I'll just send you to this page for an example you might be able to modify and apply to your needs. Good luck!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
bakersburg9
post Jul 22 2019, 12:15 PM
Post#5



Posts: 5,573
Joined: 2-November 04
From: Downey, CA


DBguy from San Diego - THANKS !!!!! cool.gif

Steve
Go to the top of the page
 
theDBguy
post Jul 22 2019, 12:18 PM
Post#6


Access Wiki and Forums Moderator
Posts: 76,577
Joined: 19-June 07
From: SunnySandyEggo


Don't mention it. Good luck!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
ADezii
post Jul 22 2019, 12:32 PM
Post#7



Posts: 2,689
Joined: 4-February 07
From: USA, Florida, Delray Beach


Here is a little Demo that I created for you to hopefully illustrate how you can Rename all Files in a Folder. The following Code will:
  1. Rename all Files in the C:\Test Folder to BaseFileName & Suffix & Extension.
  2. Define your own Folder and Suffix in the USER DEFINED SECTION.
  3. Code Definition:
    CODE
    Dim strFile As String
    Dim strBaseName As String
    Dim strExt As String

    '****** USER DEFINED SECTION ******
    Const conFOLDER = "C:\Test"
    Const conSUFFIX = "_July_18"
    '**********************************

    strFile = Dir$(conFOLDER & "\*.*")

    Do While strFile <> ""
      strBaseName = Left$(strFile, InStrRev(strFile, ".") - 1)
        Name conFOLDER & "\" & strFile As conFOLDER & "\" & _
             Replace(strFile, strBaseName, strBaseName & conSUFFIX)
          strFile = Dir
    Loop

    Close #1
  4. Files in C:\Test Folder prior to Code Execution:
    CODE
    Five.pdf
    Four.mdb
    My Final Resume_July_18.docx
    One.JPG
    Seven.accdb
    Six.mdb
    Three.zip
    Two.txt
  5. Files in C:\Test Folder after Code Execution:
    CODE
    Five_July_18.pdf
    Four_July_18.mdb
    My Final Resume_July_18.docx
    One_July_18.JPG
    Seven_July_18.accdb
    Six_July_18.mdb
    Three_July_18.zip
    Two_July_18.txt
  6. Hopefully, this is what you are looking for.

Go to the top of the page
 
bakersburg9
post Jul 22 2019, 12:36 PM
Post#8



Posts: 5,573
Joined: 2-November 04
From: Downey, CA


Adezii,

I'll get to work on that ASAP - thanks !!!!! cool.gif

question: the Close#1 - that's code, or did you mean to comment that line out - I don't follow what it's doing if it is supposed to be code, which I'm guessing it is - never seen anything like that...

thanks again!

Steve
This post has been edited by bakersburg9: Jul 22 2019, 12:40 PM
Go to the top of the page
 
ADezii
post Jul 22 2019, 01:38 PM
Post#9



Posts: 2,689
Joined: 4-February 07
From: USA, Florida, Delray Beach


Close #1, my apologies/my mistake. You can remove it.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    18th November 2019 - 05:11 PM