Thread: The C system command with long filenames in windowsXP

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Hm. What is this escape sequence: \*?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  2. #2
    Fountain of knowledge.
    Join Date
    May 2006
    Posts
    794
    Quote Originally Posted by Dave_Sinkula
    Hm. What is this escape sequence: \*?

    It's not an escape sequence it is the MSDOS folder seperator as in:-
    C:\DOCUME~1\HP_OWNER\DESKTOP\TESTDIR\2E6D1\196135~ 1.LOG

    I want to list all the ".log" files so I want *.log

    So the last bit would become:-

    C:\DOCUME~1\HP_OWNER\DESKTOP\TESTDIR\2E6D1\*.LOG

    Of course when I was printing the stuff into a string with sprint I had to do something like

    Code:
    sprintf (asrting, "C:\\DOCUME~1\\HP_OWNER\\DESKTOP\\TESTDIR\\2E6D1\\*.LOG")

    (or something like that, it just an example)

    You can see in the above the long filenames have been truncated.



    Anyway.... I have though of a 'work around' in the meantime. What I can do is just rename all the folders to short filenames and then work with them. This is OK because I actually want to rename the folders anyway, based on the date of the files within them, thus if the files are dated 09/09/2006 (todays date) the folder will be named "09092006". This will meet my needs for what I want to do, however I would still like to know how to 'solve' the original problem.
    Now I just need to find a good folder renaming utiliity, any recommendations?

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I want to list all the ".log" files so I want *.log
    If you append a /X onto your dir, it will show you both the short and long filename. Last time I did something like this (in another language), I just wrote up a short bat file with all the various dir options I wanted (it has quite a list, type dir /? to see them all), and had it's output go into my program's input.

    Renaming lots of files is a poor idea, imo. Learn to work with your OS, not work around it.

    Adak
    Last edited by Adak; 09-08-2006 at 08:33 PM.

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by esbo
    It's not an escape sequence it is the MSDOS folder seperator as in:-
    C:\DOCUME~1\HP_OWNER\DESKTOP\TESTDIR\2E6D1\196135~ 1.LOG
    Yes, I knew that. The same as I know a forward slash is easier to work with.

    Perhaps the MSDN has something about converting long filenames to short filenames?
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #5
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Quote Originally Posted by Dave_Sinkula
    Yes, I knew that. The same as I know a forward slash is easier to work with.

    Perhaps the MSDN has something about converting long filenames to short filenames?
    Talking of which, do these functions "take" forward slashes as back slashes in a Windows environment?

    Just occured to me I've never tried and have been at the hands of \\ for years.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  6. #6
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    Quote Originally Posted by ahluka
    Talking of which, do these functions "take" forward slashes as back slashes in a Windows environment?

    Just occured to me I've never tried and have been at the hands of \\ for years.
    http://groups.google.com/group/comp....3ac81f37b60ca9
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inserting a swf file in a windows application
    By face_master in forum Windows Programming
    Replies: 12
    Last Post: 05-03-2009, 11:29 AM
  2. hton long long
    By carrotcake1029 in forum C Programming
    Replies: 1
    Last Post: 06-01-2008, 08:26 PM
  3. error: double free or corruption
    By dsc in forum C Programming
    Replies: 3
    Last Post: 04-03-2008, 09:26 AM
  4. need help
    By emperor in forum C Programming
    Replies: 1
    Last Post: 03-04-2002, 12:26 PM
  5. can someone check this out and let me know ?
    By javaz in forum C Programming
    Replies: 5
    Last Post: 01-21-2002, 02:13 PM