Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: New member, New DOS adventurer.  (Read 19553 times)

0 Members and 1 Guest are viewing this topic.

robertwig

    Topic Starter


    Rookie
  • The Dos and Don'ts of my new life
    • Experience: Beginner
    • OS: Windows 7
    Re: New member, New DOS adventurer.
    « Reply #15 on: January 22, 2014, 12:18:31 PM »
    After my tantrum, I whipped this up.   

    Code: [Select]
    @echo off
    for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
        if exist %%a:\ for /f "delims=" %%b in ('dir "%%a:\foldername" /ad /b /s') do set "var=%%b" & goto :done
    )
    :done

    It's just very annoying when people ask for a solution and you provide one, and they didn't say SORRY, I CAN"T USE ANY TEMPORARY FILES in the first place.

    Foxidrive;

    I'm sorry if you got this impression. It was not a criticism or complaint in any way. I'm new to dos and learning here. The reason (which I did not elucidate on in my original request, is that I do not want to generate any files on the client machine. I want my code to be somewhat unobtrusive. I apologize if I ticked you off. I am learning quite a lot from this thread and I appreciate your time.

    Squashman



      Specialist
    • Thanked: 134
    • Experience: Experienced
    • OS: Other
    Re: New member, New DOS adventurer.
    « Reply #16 on: January 22, 2014, 12:23:55 PM »
    But the temp file was just being redirected into a variable anyways.  You could have then just deleted the temp file.  It would have been on the system for all of 2 seconds.

    robertwig

      Topic Starter


      Rookie
    • The Dos and Don'ts of my new life
      • Experience: Beginner
      • OS: Windows 7
      Re: New member, New DOS adventurer.
      « Reply #17 on: January 22, 2014, 12:28:10 PM »
      But the temp file was just being redirected into a variable anyways.  You could have then just deleted the temp file.  It would have been on the system for all of 2 seconds.

      Your point is valid, and it may just be semantics but If my code failed for some reason it might be possible that the file did not get deleted. It may be a slim issue and as I said, I'm new to this but I didn't want to have the possibility of leaving any footprint so to speak.

      Lemonilla



        Apprentice

      • "Too sweet"
      • Thanked: 70
      • Computer: Specs
      • Experience: Experienced
      • OS: Windows 7
      Re: New member, New DOS adventurer.
      « Reply #18 on: January 22, 2014, 12:59:20 PM »
      To fix the point you brought up, about having the program fail and leave behind a file, you can always add a point at the beginning to check to see if there is a temporary file, and if so delete it.  This would ensure that the next time you draw from the temporary file you don't get the wrong info. To do this you use a "modified" if statement.

      if exist temp.file del temp.file

      I like to add the /f switch to 'del' in case some other program decides it needs to read the file at that exact time (which has happened to me more times than I like to think about.)
      Quote from: patio
      God Bless the DOS Helpers...
      Quote
      If it compiles, send the files.

      Salmon Trout

      • Guest
      Re: New member, New DOS adventurer.
      « Reply #19 on: January 22, 2014, 01:40:24 PM »
      First post:

      Quote
      I have been spending some time with DOS in hopes of gaining the ability to program some batch files for my home pc.

      Later:

      Quote
      I do not want to generate any files on the client machine. I want my code to be somewhat unobtrusive

      Later still:

      Quote
      I didn't want to have the possibility of leaving any footprint

      Hmmm.... first it's "my home PC", then it's a "client machine" where you don't want someone (the owner?) to notice what you are doing? Sorry if this sounds supicious, but how do you explain the change of intended machine, and the reason you want the code to operate in an "unobtrusive" manner, and not leave "footprints"?



      robertwig

        Topic Starter


        Rookie
      • The Dos and Don'ts of my new life
        • Experience: Beginner
        • OS: Windows 7
        Re: New member, New DOS adventurer.
        « Reply #20 on: January 22, 2014, 02:52:10 PM »
        First post:

        Later:

        Later still:

        Hmmm.... first it's "my home PC", then it's a "client machine" where you don't want someone (the owner?) to notice what you are doing? Sorry if this sounds supicious, but how do you explain the change of intended machine, and the reason you want the code to operate in an "unobtrusive" manner, and not leave "footprints"?

        It's going to be a tool for backup purposes which I and my family members pc's need. Therefore I want to make sure I do not alter the contents of their hard drives but the backups will ultimately go to a network drive we share in our home.
        With the questions I'm asking which are very basic to skilled dos people I am far from capable of being subversive.

        Squashman



          Specialist
        • Thanked: 134
        • Experience: Experienced
        • OS: Other
        Re: New member, New DOS adventurer.
        « Reply #21 on: January 22, 2014, 04:00:53 PM »
        Leaving a 10 byte temp file is no big deal. Especially if you just use the Temp directory to write it to.  Nobody will even know it is there because most people dont even bother to clear out the temp folders. Windows and all kinds of programs dump files into temp folders every day you use your computer. Kind of maiking a mountain out of a mole hill.

        patio

        • Moderator


        • Genius
        • Maud' Dib
        • Thanked: 1769
          • Yes
        • Experience: Beginner
        • OS: Windows 7
        Re: New member, New DOS adventurer.
        « Reply #22 on: January 22, 2014, 04:27:34 PM »
        It's going to be a tool for backup purposes which I and my family members pc's need. Therefore I want to make sure I do not alter the contents of their hard drives but the backups will ultimately go to a network drive we share in our home.
        With the questions I'm asking which are very basic to skilled dos people I am far from capable of being subversive.

        Unfortunately i'm with Salmon on this...if you are offended oh well.
        " Anyone who goes to a psychiatrist should have his head examined. "

        robertwig

          Topic Starter


          Rookie
        • The Dos and Don'ts of my new life
          • Experience: Beginner
          • OS: Windows 7
          Re: New member, New DOS adventurer.
          « Reply #23 on: January 22, 2014, 08:56:10 PM »
          Ok, I really don't want to argue over the use or not of temp files. It's just a matter of choice is it not? I take no offence in anyone's statements. I just prefer to not to use that approach.

          This is the approach I am currently working on:

           for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
              if exist %%a:\ for /f "delims=" %%b in ('dir "%%a:\MyOFFSetupFiles" /ad /b /s') do set "var=%%b" & goto :done
          )
          :done

          It works if the file exists, but if it doesn't the batch file just hangs there. I am having some difficulties with syntactically using the "else" to echo back that the file does not exist and to force an exit after the echo. I presume I could test var for null data as well and generate an appropriate echo message. Again I am having difficulty establishing where to fit in the Else appropriately.

          Any assistance with this would be appreciated

          Best Regards;


          foxidrive



            Specialist
          • Thanked: 268
          • Experience: Experienced
          • OS: Windows 8
          Re: New member, New DOS adventurer.
          « Reply #24 on: January 22, 2014, 11:15:05 PM »
          This is the approach I am currently working on:

           for %%a in (c d e f g h i j k l m n o p q r s t u v w x y z) do (
              if exist %%a:\ for /f "delims=" %%b in ('dir "%%a:\MyOFFSetupFiles" /ad /b /s') do set "var=%%b" & goto :done
          )
          :done

          It works if the file exists, but if it doesn't the batch file just hangs there.

          Not at all.  If the folder doesn't exist then it will read every drive in every folder, and then when it doesn't find it, it will exit.

          You probably have either several drives or a slow network drive and it was still checking.


          robertwig

            Topic Starter


            Rookie
          • The Dos and Don'ts of my new life
            • Experience: Beginner
            • OS: Windows 7
            Re: New member, New DOS adventurer.
            « Reply #25 on: January 23, 2014, 06:36:00 AM »
            Not at all.  If the folder doesn't exist then it will read every drive in every folder, and then when it doesn't find it, it will exit.

            You probably have either several drives or a slow network drive and it was still checking.

            Thanks for the reply Foxidrive;

            I only have a C: and an E: drive(CD Rom) in my system and the program just sits there without coming back with a cursor return when the folder does not exist. If the folder exists, everything works fine. I'm puzzled by this. I left it running for 5 minutes and it still did not return. Do you have any idea what might cause this

            Squashman



              Specialist
            • Thanked: 134
            • Experience: Experienced
            • OS: Other
            Re: New member, New DOS adventurer.
            « Reply #26 on: January 23, 2014, 06:40:10 AM »
            Is the /S option really needed?

            robertwig

              Topic Starter


              Rookie
            • The Dos and Don'ts of my new life
              • Experience: Beginner
              • OS: Windows 7
              Re: New member, New DOS adventurer.
              « Reply #27 on: January 23, 2014, 06:57:15 AM »
              Is the /S option really needed?

              I can do without it. Why do you ask?

              Squashman



                Specialist
              • Thanked: 134
              • Experience: Experienced
              • OS: Other
              Re: New member, New DOS adventurer.
              « Reply #28 on: January 23, 2014, 07:09:26 AM »
              I can do without it. Why do you ask?
              If you can do without it then you should know what the /S option does and realize why it is taking so long to run when the folder does not exist.

              robertwig

                Topic Starter


                Rookie
              • The Dos and Don'ts of my new life
                • Experience: Beginner
                • OS: Windows 7
                Re: New member, New DOS adventurer.
                « Reply #29 on: January 23, 2014, 07:23:58 AM »
                Yes I know it looks into recursive dir and files but I sure didn't think it would take so long. I will remove it and see what happens. Thanks for the tip.