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

Author Topic: re-archiving a file without...  (Read 9079 times)

0 Members and 1 Guest are viewing this topic.

chophillies

    Topic Starter


    Greenhorn

    • Experience: Familiar
    • OS: Windows 7
    re-archiving a file without...
    « on: April 11, 2013, 12:34:12 AM »
    Hello everyone

    Im a bit stumped with the final question on my windows command line homework assignment. The teacher is asking me to turn the archive attribute back on for a selected file. But here is when things get hairy. I need to do it WITHOUT using the attrib command, the windows GUI or renaming the file. As far as I know these are the only 3 ways to re-enable the archive bit. So to say the least im pretty stumped. Ive exhausted google searches and cant seem to find the solution anywhere. Any help is appreciated.

    -chophillies

    BC_Programmer


      Mastermind
    • Typing is no substitute for thinking.
    • Thanked: 1140
      • Yes
      • Yes
      • BC-Programming.com
    • Certifications: List
    • Computer: Specs
    • Experience: Beginner
    • OS: Windows 11
    Re: re-archiving a file without...
    « Reply #1 on: April 11, 2013, 01:09:05 AM »
    What a ridiculous assignment.

    You can use powershell:
    Code: [Select]
    $file=Get-Item "somefile.txt"
    $file.Attributes = 'Archive'
    I was trying to dereference Null Pointers before it was cool.

    chophillies

      Topic Starter


      Greenhorn

      • Experience: Familiar
      • OS: Windows 7
      Re: re-archiving a file without...
      « Reply #2 on: April 11, 2013, 01:19:29 AM »
      Thank you for your response. Powershell is beyond the scope of this course. The solution to this question must be simpler if even possible. I've been using google and searching forums for roughly 2 and half hours now to no avail. Any other input?

      foxidrive



        Specialist
      • Thanked: 268
      • Experience: Experienced
      • OS: Windows 8
      Re: re-archiving a file without...
      « Reply #3 on: April 11, 2013, 02:07:44 AM »
      Assuming file.txt has no archive attribute, try this.

      Code: [Select]
      @echo off
      copy /b "file.txt" "file.tmp" >nul
      move /y "file.tmp" "file.txt" >nul

      chophillies

        Topic Starter


        Greenhorn

        • Experience: Familiar
        • OS: Windows 7
        Re: re-archiving a file without...
        « Reply #4 on: April 11, 2013, 02:18:02 AM »
        Unfortunately the assignment is explicit in saying copy is not allowed also. I omitted that from the OP because i felt it fell under the same category as rename. My fault for not being specific enough. Once again thanks for the help so far but im still searching.

        (Edit: Im fairly certain the professor may be looking for a command that defaults a files archive option on)
        « Last Edit: April 11, 2013, 02:28:57 AM by chophillies »

        foxidrive



          Specialist
        • Thanked: 268
        • Experience: Experienced
        • OS: Windows 8
        Re: re-archiving a file without...
        « Reply #5 on: April 11, 2013, 02:30:19 AM »
        Tell us what commands you can't use.  I'm no good at guessing. :P


        Code: [Select]
        @echo off
        move /y "file.txt" "file.tmp" >nul
        move /y "file.tmp" "file.txt" >nul

        chophillies

          Topic Starter


          Greenhorn

          • Experience: Familiar
          • OS: Windows 7
          Re: re-archiving a file without...
          « Reply #6 on: April 11, 2013, 02:39:47 AM »
          This is the exact question copied and pasted here.

          Without using the Attrib command and/or the GUI interface and/or Copying or Renamingthe file, turn on the archive attribute on the FOOT-PRO.TMS file in the \SPORTS directory. Explain how you did this.

          As stated, the fault was mine for not clarifying. You must understand this is a very simple class with a majority of the homework being "use copy or xcopy to copy all files from here to here" kid of stuff. But this question is a real curve ball and its getting to the point where i believe its a trick question.


          BC_Programmer


            Mastermind
          • Typing is no substitute for thinking.
          • Thanked: 1140
            • Yes
            • Yes
            • BC-Programming.com
          • Certifications: List
          • Computer: Specs
          • Experience: Beginner
          • OS: Windows 11
          Re: re-archiving a file without...
          « Reply #7 on: April 11, 2013, 03:46:43 AM »
          But this question is a real curve ball and its getting to the point where i believe its a trick question.
          It may or may not be a trick question.

          However, I think the 'lesson' is trying to teach you how the archive attribute works. the archive bit of a file is set whenever it is modified. So you can "touch" the file. You can do this by echoing nothing to the end of it. To echo nothing, you can type the NUL file, then redirect that to the end of the file using >>
          Code: [Select]
          type nul>>\SPORTS\FOOT-PRO.TMS
          I was trying to dereference Null Pointers before it was cool.

          foxidrive



            Specialist
          • Thanked: 268
          • Experience: Experienced
          • OS: Windows 8
          Re: re-archiving a file without...
          « Reply #8 on: April 11, 2013, 06:07:56 AM »
          However, I think the 'lesson' is trying to teach you how the archive attribute works. the archive bit of a file is set whenever it is modified. So you can "touch" the file. You can do this by echoing nothing to the end of it. To echo nothing, you can type the NUL file, then redirect that to the end of the file using >>
          Code: [Select]
          type nul>>\SPORTS\FOOT-PRO.TMS

          Touching the timestamp with "copy /b file.txt+,," and "type nul >> file" don't change the archive attribute here.

          FWIW using the MOVE command technically doesn't rename the file, or copy it.  At least not using the verboten commands.

          Ocalabob



            Rookie

            Thanked: 4
            • Experience: Familiar
            • OS: Windows 7
            Re: re-archiving a file without...
            « Reply #9 on: April 11, 2013, 12:00:47 PM »
            Greetings chophillies,
            Using WIN7 from a command prompt the line below worked for me:

            Code: [Select]
            echo>>FOOT-PRO.TMS
            Best wishes!

            chophillies

              Topic Starter


              Greenhorn

              • Experience: Familiar
              • OS: Windows 7
              Re: re-archiving a file without...
              « Reply #10 on: April 11, 2013, 02:13:17 PM »
              Thank you for your help and time guys. I provided echo>>FOOT-PRO as my solution for the question. Thanks all around as many correct solutions were given. Great forum and great help.

              -chophillies

              BC_Programmer


                Mastermind
              • Typing is no substitute for thinking.
              • Thanked: 1140
                • Yes
                • Yes
                • BC-Programming.com
              • Certifications: List
              • Computer: Specs
              • Experience: Beginner
              • OS: Windows 11
              Re: re-archiving a file without...
              « Reply #11 on: April 11, 2013, 04:05:11 PM »
              Touching the timestamp with "copy /b file.txt+,," and "type nul >> file" don't change the archive attribute here.
              Former doesn't work here either. Latter doesn't work either. I think I may have mistyped >> as > at the command line (which definitely changes the file) when testing, because several of the test copies are empty.

              I honestly think this is possibly the dumbest CMD-based question that could ever appear in a learning environment, because regardless of the "right way" to do it, it's trivia. I mean, when are you going to be without attrib, move, or other file management commands? At the very least you will ALWAYS have copy, so it makes the question moot.

              I'd be with you on the Move command, but again, this is one of those dumb questions where the instructor arbitrarily limits your command set for no reason, and it seems like they have some specific solution in mind. Move as an answer could either be the desired answer, or be yet another arbitrarily unavailable command.

              If nothing else, the OP ought to have learned to at least test provided solutions, rather than assume they work.
              I was trying to dereference Null Pointers before it was cool.

              chophillies

                Topic Starter


                Greenhorn

                • Experience: Familiar
                • OS: Windows 7
                Re: re-archiving a file without...
                « Reply #12 on: April 11, 2013, 09:12:50 PM »
                Agreed. This is doing nothing but teaching people the wrong way to do things. I did in fact assume it worked at the time i wrote the post but i ended up testing before i submitted and it didnt work. I opted to give a more general answer and hope for partial points than providing an incorrect answer. Since the assignment is time sensative and i figure 5+ hours of research was impeding me from continuing with other assignments for other classes(bash scripting). So I opted to settle for the possible partial points.

                Geek-9pm


                  Mastermind
                • Geek After Dark
                • Thanked: 1026
                  • Gekk9pm bnlog
                • Certifications: List
                • Computer: Specs
                • Experience: Expert
                • OS: Windows 10
                Re: re-archiving a file without...
                « Reply #13 on: April 11, 2013, 09:26:54 PM »
                Thank you for your response. Powershell is beyond the scope of this course. The solution to this question must be simpler if even possible. I've been using google and searching forums for roughly 2 and half hours now to no avail. Any other input?
                Thanks to  BC_Programmer for the Power Shell example.
                We need to find those teachers who are telling students to study old DOS commands. They should  also teach Latin, another dead language.

                BC_Programmer


                  Mastermind
                • Typing is no substitute for thinking.
                • Thanked: 1140
                  • Yes
                  • Yes
                  • BC-Programming.com
                • Certifications: List
                • Computer: Specs
                • Experience: Beginner
                • OS: Windows 11
                Re: re-archiving a file without...
                « Reply #14 on: April 12, 2013, 12:23:22 AM »
                Thanks to  BC_Programmer for the Power Shell example.
                We need to find those teachers who are telling students to study old DOS commands. They should  also teach Latin, another dead language.
                But without Latin we'll have to put phrases on coins that people can read!

                I definitely agree re: the Command Prompt Commands. On the one hand, Command Prompt is here to stay on Windows Systems, but on the other hand, MS has been trying since Windows 98 to replace it with something more modern (Win98 being the first appearance of the Windows Scripting Host, to my understanding), and of course more recently, PowerShell, which is now included in Windows 7. Both of which are a lot more versatile once you've understood their particular paradigms than standard Batch Command Scripts, which often rely on NT Command Extensions and so forth.

                Bash and *nix CLI commands being taught I can understand- those have been relatively unchanged and something of a fixture on the Server-Side so it can be very useful.
                I was trying to dereference Null Pointers before it was cool.