Announcement

Collapse
No announcement yet.

powerbasic's "NAME" statement not working with changing case of letters

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • powerbasic's "NAME" statement not working with changing case of letters

    I want to be able to rename a file in windows 10 by keeping the name the same but only changing the filename to upper-case or lower-case or mixed-case. powerbasic's name command not successful at doing that. is there an alternative in powerbasic for windows I'm not aware of or do I need to go to windows API ?

  • #2
    Windows filenames are not case sensitive.

    Rename it with a temporary name and then again with the old name with different captialisation.

    Comment


    • #3
      I have tried that method but that adds triple amount of time on a server to pc environment which is not accectable when there are tens of thousands of files to work with in a given instance.

      I was hoping there was a better solution.

      when I right click on a filename in windows 10 explorer it allows me to just change the case of any letters in the filename then hitting enter allows changes so I know windows supports it.

      Comment


      • #4
        Correction,
        What file system?
        I just checked and
        NAME "test2.bas" AS "TEST2.BAS"
        works in Win 7 on an NTFS volume.

        Comment


        • #5
          As I mentioned in the original post - windows 10

          and I tried it on these different file volumes: NTFS and FAT32 and FAText on windows 10 with the same result.

          And if it was a window's setting or security issue I dont think it would let me do it successfully from windows explorer manually with keyboard I'm thinking, although I might be wrong with that assumption.

          Comment


          • #6
            Kevin, like Stuart shows above...in a past life I needed to rename files to “fix” only capitalization. I was able to do this even on a file share on a Windows server volume formatted NTFS. I don’t know if NTFS is required vs FAT. Is NAME command giving you an “ERROR” or just not the results you need? Are you using Windows Explorer...maybe F5 for refresh?

            Comment


            • #7
              Just tested NAME “TEST123.TXT” AS “Test123.txt” on Windows 10 local NTFS volume...works as advertised...file becomes “Test123.txt”

              Comment


              • #8
                Is NAME command failing? Is it in a TRY/CATCH/END TRY...is it throwing an ERROR... maybe file is open and can’t be renamed.

                Comment


                • #9
                  I have tried that method but that adds triple amount of time on a server to pc environment which is not accectable when there are tens of thousands of files to work with in a given instance.

                  I was hoping there was a better solution.
                  There may be a better solution.. but you'd have to describe the application so we can devise a way around all the renaming.

                  Alternately, if you have to wait for the renaming, you could put the renaming task into a thread function which looks like.
                  Code:
                  FUNCTION  RenameFileThread (someparam) AS LONG
                     NAME  filename AS filename
                     Put filename into a queue  (eg the PB queue object)
                  END FUNCTION
                  And in your main program, get your input from the queue which contains the renamed file names.

                  But it sounds simpler to me to process the "wrongly named" file and when you are done with it put the renaming task off into a background thread and let it run there whilst your main program does more imortant stuff.

                  But I'm just crapshooting because I don't know the application.

                  And FWIW, this "change case of filename" challenge has come up here several times over the years and the answer was and is "temp name, newname with desired capitalization."

                  MCM
                  Michael Mattias
                  Tal Systems Inc. (retired)
                  Racine WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    I tried what you suggested stuart, and it actually adds only about 35% more time to the process so I will hafta use that method for now until I can find a better solution.

                    thanks for the info stuart.

                    To answer your question michael rice: no powerbasic does not throw an error code. it executes normally without actually changing the filename even after doing a refresh in explorer to make sure it wasnt a windows refresh issue.

                    thanks michael mattias for the info. i'll give that a try to see what results I get.

                    Comment


                    • #11
                      Kevin, does it ever work on your system? And just fails sometimes? It works without failure on my system here now.

                      You could always shell the OS rename command... REN “TEST123.TXT” “Test123.txt” ... works just fine as well from the Win/10 command line

                      Where I used to work...we would receive thousands of files per night from one of our vendors. The files all named something like ACCOUNT164545NAMERICE.PDF ... My teams that worked with the files really disliked the all upper case. So, I wrote a little PB program to rename them... Account164545NameRice.pdf ... long story short, I don’t know of it ever failing. Which didn’t surprise me..because it was one of the simplest programs I’ve ever written.

                      What does surprise me is that you and I are getting different results while renaming a file...

                      MCM do you have a post in mind that describes in more detail the challenges with NAME and where/when these challenges manifest? I’m interested in the cause of this...why it works sometimes and not others

                      Comment


                      • #12
                        thanks michael mattias for the info. i'll give that a try to see what results I get.
                        I appreciate your faith BUT..

                        Why try it right away? I acknowledged (admitted?) I was crapshooting because I don't know the application. If you describe the application you will get the benefit of ideas from lots more people, most of whom have been actively programming far more recently than have I.
                        Michael Mattias
                        Tal Systems Inc. (retired)
                        Racine WI USA
                        [email protected]
                        http://www.talsystems.com

                        Comment


                        • #13
                          You could always shell the OS rename command... REN “TEST123.TXT” “Test123.txt” ... works just fine as well from the Win/10 command line
                          I would recommend against that, sir, as it will make you dependent on this version of the command shell and/or operating system.

                          MCM do you have a post in mind that describes in more detail the challenges with NAME and where/when these challenges manifest? I
                          I was NOT referring to the challenge with the PowerBasic NAME verb; I was referring to the APPLICATION challenge and how the solution to rename files with desired upper/lower case letters has come up here.

                          I’m interested in the cause of this...why it works sometimes and not others
                          See my pooh-poohing of your suggestion... it can be a function of the specific command shell and operating system in use.


                          MCM
                          Michael Mattias
                          Tal Systems Inc. (retired)
                          Racine WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                          • #14
                            MCM

                            I don’t think either of us thinks there is a problem with the PB verb NAME... It would have been discovered, reported and fixed long ago.

                            But apparently you can use it and get mixed results which is why I was asking if you had a post in mind that shows what seems to cause it... Thanks for letting me know the issue exists, I will go see if I can find the related forum topics.

                            Comment


                            • #15
                              A way that always worked fine for me - also in Win10. Many fFlags options, but I settled for these. Can also be used with %FO_MOVE to move files, etc.
                              '
                              Code:
                              FUNCTION SHRenameFile(sFrom AS STRING, sTo AS STRING) AS LONG
                                LOCAL shfo AS SHFILEOPSTRUCT
                                shfo.hWnd   = %NULL    ' <- can be a dialog handle to
                                shfo.wFunc  = %FO_RENAME
                                shfo.pFrom  = STRPTR(sFrom)
                                shfo.pTo    = STRPTR(sTo)
                                shfo.fFlags = %FOF_RENAMEONCOLLISION OR %FOF_SILENT
                                FUNCTION  = SHFileOperation(shfo)
                              END FUNCTION
                              '

                              Comment


                              • #16
                                kevin,
                                I want to be able to rename a file in windows 10 by keeping the name the same but only changing the filename to upper-case or lower-case or mixed-case. powerbasic's name command not successful at doing that. is there an alternative in powerbasic for windows I'm not aware of or do I need to go to windows API ?
                                No ERR test?
                                Code:
                                FUNCTION PBMAIN () AS LONG
                                 NAME EXE.FULL$ AS LCASE$(EXE.FULL$)
                                 IF ERR THEN ? ERROR$
                                END FUNCTION
                                How long is an idea? Write it down.

                                Comment


                                • #17
                                  mike doty your code you entered doesnt work in my situation. "name" command does not work that way. it does nothing to filename. i've refreshed the window in explorer and there is no error created and the file is not open. thats the reason I am posing the question on here. I see many others over the years have asked the exact same question I have as Mr. Mattias has mentioned with no real answers.

                                  I'll get on microsoft's Q & A forum and look it up and see if there is a fix on OS side.

                                  Comment


                                  • #18
                                    Does DIR work?
                                    Are you renaming across drives or on a network?
                                    Can you post an example of the exact name statement so we can duplicate it?
                                    Are you using a wildcard statement?
                                    How long is an idea? Write it down.

                                    Comment


                                    • #19
                                      Originally posted by Mike Doty View Post
                                      Code:
                                      FUNCTION PBMAIN () AS LONG
                                      NAME EXE.FULL$ AS LCASE$(EXE.FULL$)
                                      IF ERR THEN ? ERROR$
                                      END FUNCTION
                                      I'm surprised that works, but it does. I wouldn't have expected to be able to rename an exe file while it is running and locked. (You can't delete it)

                                      Comment


                                      • #20
                                        Originally posted by kevin oliverson View Post
                                        mike doty your code you entered doesnt work in my situation. "name" command does not work that way. it does nothing to filename. i've refreshed the window in explorer and there is no error created and the file is not open. thats the reason I am posing the question on here. I see many others over the years have asked the exact same question I have as Mr. Mattias has mentioned with no real answers.

                                        I'll get on microsoft's Q & A forum and look it up and see if there is a fix on OS side.
                                        NAME changing case works on my system, it works on Michael Rice's system and it works on Mike Doty's system. So far the only system it isn't working on appears to be yours! Could it be something in your system like directory access rights or anti-virus

                                        Comment

                                        Working...
                                        X